简体   繁体   中英

Entity Framework Code First Migrations

on running following command

pm> Update-Database

getting following error

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> 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.

Your EF version and Project Version is not Equal. your Entity Framework is ver 6 of .Net 4 but your project use .net 4.5 Project by .net version 4.5 must use EF for .Net4.5

I had the same problem (EF 6.1.3 & net462) and I tried all the answers, but nothing fixed the problem. When I eventually switched to Release configuration, it worked liek a charm.

Not sure what's wrong with Debug, since they are almost identically, except for debug trace etc.

Hope this helps other people in the future.

Not the ideal solution, but I switched back to Entity Framework 5.0.0 and the problem went away. Found this useful link .

Hi I had a similar problem. After a long time I found that one project referenced Entity Framework version 6.1.1 and in another project version 6.1.3 is referenced in same solution. I removed 6.1.3 from the package manager console. Problem is finally solved.

Hope this will help someone

I had the same problem. After spending some hours to fix this. What fixed the problem was: I closed the project, created a new one with the same name, copied my folders and classes I created to the new project and downloaded the packages I needed through nuget. Then Add-Migration ...... everything went well afterwards.

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