Entity Framework Migrations Error : Sequence contains no elements - Timestamp

.net c# entity-framework-6 visual-studio-2015

Question

I created a project in Visual Studio 2015 using the code Code First for entity framework 6.

  • [6.0.0] EntityFramework .0]
  • mysql.data.entity.EF6 [6.8.3.0]
  • I'm testing migrations.

    command: Add-Migration Initial
    error: Sequence contains no matching element

    I've been experimenting a lot, and I think I've identified the problem.

    [Timestamp]
    public byte[] RowVersion { get; set; }
    

    First is an example model-code.

    using MySql.Data.Entity;
    using System.Data.Common;
    using System.Data.Entity;
    using System.ComponentModel.DataAnnotations;
    using System.ComponentModel.DataAnnotations.Schema;
    
    namespace TokoBersama.Model
    {
        // Code-Based Configuration and Dependency resolution
        [DbConfigurationType(typeof(MySqlEFConfiguration))]
        public class MySqlDatabaseConnection : DbContext
        {
    
    
            #region Tabels
    
            public DbSet<returnpenjualan> ReturnPenjualan { get; set; }         
    
            #endregion
    
            #region member Event
            public MySqlDatabaseConnection()
                : base("name=myConnectionString")
            {
    
            }
    
            public MySqlDatabaseConnection(DbConnection existingConnection, bool contextOwnsConnection)
          : base(existingConnection, contextOwnsConnection)
            {
    
            }
    
            //protected override void OnModelCreating(DbModelBuilder modelBuilder)
            //{
            //    base.OnModelCreating(modelBuilder);
            //
            //    Map entity to table
            //    modelBuilder.Entity<jenis>().MapToStoredProcedures();
            //}
    
            #endregion
    
        }
    
        #region tabels
    
        public class returnpenjualan
        {
            [Key]
            [StringLength(12)]
            public string frjb { get; set; }
    
            [Required]
            [StringLength(12)]
            public string fjb { get; set; }
    
            //THE CAUSE OF ERROR
            [Timestamp]
            public byte[] RowVersion { get; set; }
    
            [Required]
            [StringLength(15)]
            public string kepada { get; set; }
    
            [Required]
            [StringLength(45)]
            public string alamat { get; set; }
    
    
            [StringLength(45)]
            public string ktp { get; set; }
    
            [Required]
            public double jumlahreturnpenjualan { get; set; }
    
            [Required]
            [StringLength(45)]
            public string username { get; set; }
        }
    
        #endregion
    
    }
    

    ASK
    I've looked up tutorials and the like for utilising "Timestamp" in DataAnnotation, but I always get the same response. Am I missing something?

    1
    0
    6/23/2017 6:29:40 AM

    Popular Answer

    I have been looking for timestamp in mysql and utilising this code for the time being, but I'm not sure whether this is the best answer to my query. If you have any suggestions, please respond.

    [Column(TypeName = "timestamp")]
    public DateTime RowVersion { get; set; }
    
    0
    6/23/2017 7:12:46 AM


    Related Questions





    Related

    Licensed under: CC-BY-SA with attribution
    Not affiliated with Stack Overflow
    Licensed under: CC-BY-SA with attribution
    Not affiliated with Stack Overflow