简体   繁体   English

我的C#Entity Frameworks项目是否闹鬼?

[英]Is my C# Entity Frameworks project haunted?

I am working on a .NET MVC solution and I get the error below when using the Package Manager Console to Add-Migration or update the SQL server. 我正在研究.NET MVC解决方案,在使用程序包管理器控制台Add-Migration或更新SQL服务器时,我收到以下错误。

System.TypeInitializationException: The type initializer for 'System.Data.Entity.SqlServer.SqlProviderServices' threw an exception. System.TypeInitializationException:'System.Data.Entity.SqlServer.SqlProviderServices'的类型初始值设定项引发异常。 ---> System.TypeLoadException: Method 'ExecuteAsync' in type 'System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy' from assembly 'EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' does not have an implementation. ---> System.TypeLoadException:程序'System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy'中的方法'ExecuteAsync'来自程序集'EntityFramework.SqlServer,Version = 6.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'没有实现。

What is interesting is that the code works if it is run on a colleague's computer (ie when pulled from git) or when placed into a new project. 有趣的是,如果代码在同事的计算机上运行(即从git中提取)或放入新项目时代码可以正常工作。 Other projects in the solution work fine with the Package Manager Console. 解决方案中的其他项目可以使用Package Manager控制台正常运行。

When this project was created, Entity Frameworks 6.1.3 was installed before the .Net target framework was changed from 4 to 4.5. 创建此项目时,在.Net目标框架从4更改为4.5之前安装了Entity Frameworks 6.1.3。 This seems to be the cause of the problem, as a new project, created with the target framework set before Entity Frameworks is installed, works fine. 这似乎是问题的原因,因为在安装实体框架之前使用目标框架设置创建的新项目工作正常。

We have tried: 我们尝试过:

  • Reinstalling Entity Frameworks 6.1.3 (in fact removing and restoring all nuget packages) 重新安装Entity Frameworks 6.1.3(实际上删除并恢复所有nuget包)
  • Deleting local branch and removing files from the filesystem, before pulling code (which works on a colleague's PC) from git 在从git中提取代码(在同事的PC上工作)之前删除本地分支并从文件系统中删除文件
  • Using the nuget command line to clear all local cached packages 使用nuget命令行清除所有本地缓存​​的包
  • Many combinations of the above 以上的许多组合

In all cases the error persists. 在所有情况下,错误仍然存​​在。

There must be a location where more data or configurations are stored related to the project, which are not managed by git and that are causing the error. 必须存在一个位置,其中存储与项目相关的更多数据或配置,这些数据或配置不由git管理并且导致错误。 Any ideas about where these data or configurations are stored? 有关这些数据或配置存储位置的任何想法?

I cannot comment yet, need 50 xp. 我还不能评论,需要50 xp。

Anyway please check your app/web config file, see if the version of EF is still the same. 无论如何,请检查您的app / web配置文件,看看EF的版本是否仍然相同。 If so dubbelcheck your references, you might even need to delete them and add them manualy from you packages folder. 如果这样dubbelcheck您的引用,您甚至可能需要删除它们并从您的包文件夹中手动添加它们。

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

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