Entity framework 使用预生成的视图时引发异常

Entity framework 使用预生成的视图时引发异常,entity-framework,entity-framework-6,Entity Framework,Entity Framework 6,在我的项目中,我有以下设置 已安装EF6 代码优先迁移正在运行 使用实体框架电动工具预先生成的视图 MVC项目 到目前为止,这一直运行良好,在添加新代码后,首先进行迁移,然后重新生成视图,我可以看到以下错误: The current model no longer matches the model used to pre-generate the mapping views, as indicated by the fooClass.MappingHashValue property.

在我的项目中,我有以下设置

  • 已安装EF6
  • 代码优先迁移正在运行
  • 使用实体框架电动工具预先生成的视图
  • MVC项目
到目前为止,这一直运行良好,在添加新代码后,首先进行迁移,然后重新生成视图,我可以看到以下错误:

The current model no longer matches the model used to pre-generate the mapping views, as indicated by the fooClass.MappingHashValue property. 
Pre-generated mapping views must be either regenerated using the current model or removed if mapping views generated at runtime should be used instead. See http://go.microsoft.com/fwlink/?LinkId=318050 for more information on Entity Framework mapping views.
创建迁移时根本没有生成任何错误,迁移格式正确,数据库确实能够很好地进行迁移。运行MVC站点时会出现异常

为完整起见,模型变更如下:

public class MyClass
{  
    [Key]
    public int MyClassId
    //various other properties

    public int Version //newly added property
}
生成的迁移是:

public partial class AddingVersionNumber : DbMigration
{
    public override void Up()
    {
        AddColumn("dbo.MyClass", "Version", c => c.Int(nullable: false));
    }

    public override void Down()
    {
        DropColumn("dbo.MyClass", "Version");
    }
}
恢复到上一次迁移,删除迁移更改,然后重新生成视图也可以很好地工作

我还尝试了添加一个随机模型更改,以查看我正在更改的特定表是否有任何错误,但是这个测试更改失败了,出现了相同的错误。似乎无论我如何更改模型,都会再次出现相同的错误

我遵循的另一个测试是从项目中删除预生成的视图文件,但仍然会引发相同的异常


其他人有过类似的经历吗?

我刚刚尝试为一个工作的DbContext(EF 6.1.2)生成视图,但我得到了相同的错误。奇怪的