我已更新到EF6,但它並沒有樂趣。我創建了一個新的遷移,只是將兩個字段更改爲空。EF 6.0遷移:MigrationHistory中的ContextKey爲空
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));
}
}
當我運行update-database
我得到以下錯誤:
Cannot insert the value NULL into column 'ContextKey', table 'ScabsContext.dbo.__MigrationHistory'; column does not allow nulls. INSERT fails. The statement has been terminated.
我發現了幾篇文章提到在MigrationHistory新ContextKey領域,但沒有,回答我的問題......這是爲什麼呢字段null?有沒有一種方法(並且我需要)爲ContextKey
指定一個值?我認爲這是自動完成的?
恩,說,謝謝。 – tkt986