简体   繁体   中英

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.

System.TypeInitializationException: The type initializer for 'System.Data.Entity.SqlServer.SqlProviderServices' threw an exception. ---> 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.

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. Other projects in the solution work fine with the Package Manager Console.

When this project was created, Entity Frameworks 6.1.3 was installed before the .Net target framework was changed from 4 to 4.5. 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)
  • Deleting local branch and removing files from the filesystem, before pulling code (which works on a colleague's PC) from git
  • Using the nuget command line to clear all local cached packages
  • 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. Any ideas about where these data or configurations are stored?

I cannot comment yet, need 50 xp.

Anyway please check your app/web config file, see if the version of EF is still the same. If so dubbelcheck your references, you might even need to delete them and add them manualy from you packages folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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