3

I just installed VS 11 and created a class library project. Then I added entity framework 5 beta. Then I created a simple user class and dbcontext class. Then I used the console command, "Enable-Migrations -EnableAutomaticMigrations" which worked just fine and added the appropriate migrations directory and configuration file. The problem is when I run "Add-Migrtion InitialMigration", I get the following error.

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Data.Entity, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.

I had EF 4.2 installed previously, but I uninstalled it. In fact after I first tried this and it failed, I have uninstalled VS, SQL and anything related. Then I rebooted and simple installed visual studio 11 and tried again, but still get the same error. I am suspect this is related to the previous entity framework install, but I don't know how to get it straightened out.

I am running on Win 7 I have tried the gacutil as described here Can anyone spot why I keep getting this error testing the EF 5 beta, but it didn't find anything to remove I guess.

Community
  • 1
  • 1
Matthew
  • 1,148
  • 10
  • 17

2 Answers2

0

The best way to fix that is deleting this folder from GAC after unistall the CTP:

Windows\Microsoft.NET\assembly\GAC_MSIL\policy.4.0.system.data.entity

0

System.Data.Entity.dll 4.2.0.0 was only ever shipped as part of the EF June 2011 CTP. It looks like either the code you are compiling is referencing this assembly or some other code that it is making use of is expecting this assembly. Check the references in your project and make sure that they don't reference this assembly, and that any other projects or assemblies referenced don't themselves reference this assembly. If you find references, then you'll need to remove them and rebuild against .NET 4.5 and EntityFramework.dll 5.0.

Arthur Vickers
  • 7,503
  • 32
  • 26