0

EF migration shows empty Up() Down() methods _migrationhistory created in database but no tables has been created

code for creating model

Public partial class Student:BaseEntity

{
    public string name { get; set; }
    public string collegeName { get; set; }
    public int numberOfBooks { get; set; }
}

code for model mapping

public partial class StudentMap: EntityTypeConfiguration<Student>
    {
        public StudentMap()
        {
            this.ToTable("Students");
            this.HasKey(c => c.Id);
            this.Property(c => c.name);
            this.Property(c => c.collegeName);
            this.Property(c => c.numberOfBooks);

        }
    }

code for dbcontext

 public  class CROObjectContext: DbContext
        {
            public CROObjectContext() : base("pro-nopCommerce")
            {

            }

            public virtual DbSet<Student> students { get; set; }
    }
kiflay
  • 699
  • 2
  • 7
  • 14
  • 3
    Reset your migrations. Remove the __MigrationHistory table, delete the Migrations folder then enable-migration, add-migration Initial. There should be code in the Up() to create your objects. If not, make sure you are generating the migration off the class with your context. – Steve Greene Apr 01 '16 at 20:28
  • Thanks, it actually works fine. i don't know what wrong i was doing – kiflay Apr 04 '16 at 08:39

0 Answers0