.net - EF 5 无法验证模型的兼容性

标签 .net entity-framework

我对 ASP .Net 编程完全陌生,最近我在尝试使用 EF 5 Model First 时遇到了这个异常

Unable to verify the compatibility of the model because the DbContext instance was not created using Code First patterns. Unable to verify the compatibility of DbContext instances created from an ObjectContext or using an EDMX file.

我正在使用 Visual Studio 2012,我的解决方案项目有 2 个项目,一个用于数据模型 (EF5),另一个用于 Web 应用程序 (ASP.NET MVC 4)。

如果有人发出此错误可以帮助我。

此致

最佳答案

抱歉迟到了,我从一个月前就找到了答案,但忘了编辑我的帖子。

解决方案(对我有用,希望对你们有用):

运行包管理器控制台(我认为是工具 > 库包管理器,我的 Visual Studio 是法语)并启动以下命令:

Enable-Migrations -EnableAutomaticMigrations -ProjectName <projectName>
Update-Database -Force -Verbose -ProjectName <projectName>

通常它可以解决问题

问候。

关于.net - EF 5 无法验证模型的兼容性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14470488/

相关文章:

c# - xml 改变属性值

.net - C#中对象的错误处理

.net - 为什么 IEnumerable 比 IQueryable 快?

c# - 间歇性System.ComponentModel.Win32Exception : The network path was not found

c# - 在 .NET 控制台应用程序中为 Kestrel WebHost 构建器配置 SSL 证书

c# - 我应该如何管理大型数据表?

vb.net - 左加入 Linq 到实体 Vb.net

.net - Entity Framework 与 AssociateWith

c# - Entity Framework 。违反 UNIQUE KEY 约束

c# - WPF: Canvas 和 zIndex?它是如何工作的?