简体   繁体   English

未找到实体框架方法; 版本问题?

[英]Entity Framework method not found; version issue?

I'm working on a system built by another developer. 我正在研究另一个开发人员构建的系统。 When I run the project I get the following error at run time. 当我运行该项目时,我在运行时收到以下错误。 Is this an Entity Framework method? 这是一个实体框架方法吗? Is it from a specific version? 它来自特定版本吗? I'm not sure how to track down the source of this error. 我不确定如何追查此错误的来源。

System.MissingMethodException: Method not found: 'Void System.Data.Entity.ModelConfiguration.EntityTypeConfiguration`1.ToTable(System.String)'. System.MissingMethodException:找不到方法:'Void System.Data.Entity.ModelConfiguration.EntityTypeConfiguration`1.ToTable(System.String)'。

What I have seen happen in the past, is different projects in the solution referencing different versions of EF. 我在过去看到的是,解决方案中的不同项目引用了不同版本的EF。 I would go through each project, and make sure they reference the same version of EF. 我会浏览每个项目,并确保他们引用相同版本的EF。

Or simply right click on 或者只需右键单击即可

Solution -> Manage NuGet Packages -> Updates -> Entity Framework 解决方案 - >管理NuGet包 - >更新 - >实体框架

and this will update all of the projects to latest EF. 这将把所有项目更新为最新的EF。

The EntityTypeConfiguration<T>.ToTable(String) method is new in the Entity Framework 5 which is the first release of EF that is separate from the rest of the .NET Framework. EntityTypeConfiguration<T>.ToTable(String)方法是Entity Framework 5中的新方法,它是EF的第一个版本,与.NET Framework的其余部分分开。

Your project/solution is probably referencing the Entity Framework built-in to the .NET Framework which would be version 4. Ensure you have the correct EF binaries referenced. 您的项目/解决方案可能引用了.NET Framework内置的实体框架,该框架将是版本4.确保您引用了正确的EF二进制文件。

在我的情况下不得不重新启动Visual Studio。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM