user2426842
user2426842

Reputation:

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.

Upvotes: 4

Views: 6238

Answers (6)

damla yaşar
damla yaşar

Reputation: 1

I had the same issue because I run other project which has 6.1.3 version. then my project does not work. so I updated entity_framework same version with the other project. restarted project, run the enable-migrations command. it worked!!

happy coding

Upvotes: 0

peval27
peval27

Reputation: 1309

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.

Upvotes: 3

Dagim Belayneh
Dagim Belayneh

Reputation: 141

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.

Upvotes: 0

Narendra
Narendra

Reputation: 1412

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

Upvotes: 2

seifaei.ali
seifaei.ali

Reputation: 51

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

Upvotes: 5

philu
philu

Reputation: 874

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

Upvotes: 1

Related Questions