EF 6 code-first migrations skipped

ef-migrations entity-framework-6

Question

I have a entity framework 6 code-first project. I deleted my database and want to re-create it from scratch. When I run update-database some of the migrations do not run. That causes an error later because the database is not in the expected state.

This is the first migration that is skipped:

using System.Data.Entity.Migrations;

public partial class add_ConversationEntry_Type : DbMigration
{
    public override void Up()
    {
        AddColumn("dbo.ConversationEntry", "Type", c => c.String(nullable: false));
    }

    public override void Down()
    {
        DropColumn("dbo.ConversationEntry", "Type");
    }
} 

It looks standard. It inherits from DbMigration and does nothing weird. The next 3 also are skipped and they all affect that dbo.ConversationEntry table.

With update-datebase -verbose it shows 'Applying explicit migrations:' and lists the migrations and these are missing from that list.

I have verified that these are also in the project file. Where does update-database get the list of migrations? Why would some be skipped?

1
1
8/3/2016 3:15:47 PM

Popular Answer

Each entity framework migration consists from three files

  • entity class .cs

and additional code-behind files

  • metadata file .Designer.cs
  • database model snapshot .resx

Make sure <timestamp>_dd_ConversationEntry_Type.Designer.cs file is not missing and is included in your project.

0
9/26/2016 1:25:38 PM


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