Here is what I did before I got this error:
- Installed EF (the pre release version, 6 maybe, I dunno)
- decided I did not want, so uninstalled that and reinstalled the stable version (5)
- Truncated my database via SSMS
here is the error:
Exception calling "CreateInstanceFrom" with "8" argument(s): "Could not load file or
assembly 'EntityFramework, Version=5.0.0.0, Culture=neutral, PublicK
eyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest
definition does not match the assembly reference. (Exception from H
RESULT: 0x80131040)"
At C:\Projects\BCATracker.Web\packages\EntityFramework.6.0.0-
alpha2\tools\EntityFramework.psm1:425 char:31
+ $domain.CreateInstanceFrom <<<< (
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodTargetInvocation
Here is what I have tried:
- Delete everthing from the bin directory, rebuild.
- remove EF from nuget, delete the file in the packages directory, readd ef in nuget.
Looking at the proj file I see this:
<Reference Include="EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\EntityFramework.5.0.0\lib\net40\EntityFramework.dll</HintPath>
</Reference>
What could be a possible root cause?
I also faced this problem while using using code first migration. just update the entity framework version to Entity Framework Version 6.1.3 to resolve this. using command on Package manager console "Install-Package Entity Framework -version 6.1.3"
I figured out the problem. EntityFramework.dll needed to be in the GAC for Visual Studio to use it from the package manager.
Note: It may be wise to restart the computer entirely at this point.
I'm not sure why Visual Studio stopped seeing the DLL, but this got me past this problem.
Yes above comment is right that worked for me.
EntityFramework.dll needed to be in the GAC for Visual Studio to use it from the package manager.
Note: It may be wise to restart the computer entirely at this point.
This will definitively works.
Perform the following actions to resolve this issue:
1)Uninstall Entity Framework from the package(Manage NUGET Packages).
2)Restart Visual Studio.
3)Re-install Entity Framework again from package manager.
4)Add reference to the System.Data.Entity.
5)Run the command in package manager console Enable-Migrations -ContextTypeName Movie.Models.MovieDBContext(This is a sample context).
After this you could see the changes reflected in packages.config.
I have Windows 10. The following steps corrected the issue
Thanks to @Farshid for the initial clue to a resolution.
Install EF 6.1.3 and this will solve the problem.