Entity Framework Migrations Error : Sequence contains no elements - Timestamp

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

Question

I have been create a project in VS2015 with entity framework 6 - Code First with

  • EntityFramework [6.0.0.0]
  • mysql.data.entity.EF6 [6.8.3.0]
  • I am try Migrations

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

    I've been trying a bunch of things, and get the cause of this

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

    this is the sample model-code first

    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 search tutorial and the like for using Timestamp in DataAnnotation and get the same answer for using "Timestamp", is there something iam missing to use "Timestamp"???

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

    Popular Answer

    I have been search "mysql ef6: timestamp" and using this code for the time being, i don't know this the best solution for my question, is there some another solution, please reply

    [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