EF 6.0 Migrations: ContextKey in MigrationHistory is null

Viewed 3480

I've updated to EF6 and it hasn't been fun. I have created a new migration that is just changing two fields to nullable.

public partial class AllowNullableFieldsForImage : DbMigration
{
    public override void Up()
    {
        AlterColumn("dbo.Scabs", "image_height", c => c.Int());
        AlterColumn("dbo.Scabs", "image_width", c => c.Int());
    }

    public override void Down()
    {
        AlterColumn("dbo.Scabs", "image_width", c => c.Int(nullable: false));
        AlterColumn("dbo.Scabs", "image_height", c => c.Int(nullable: false));
    }
}

When I run update-database I get the following error:

Cannot insert the value NULL into column 'ContextKey', table 'ScabsContext.dbo.__MigrationHistory'; column does not allow nulls. INSERT fails. The statement has been terminated.

I've found a few articles mentioning the new ContextKey field in MigrationHistory but nothing that answers my questions... Why is this field null? Is there a way (and do I need to) specify a value for ContextKey? I thought that was done automatically?

2 Answers
Related