Here is what I did before I got this error:
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:
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?
Delete your Migrations folder. Create a new migration and generate a SQL script for it. In your database, delete all rows from the migrations history table. Insert a single row into the migrations history, to record that the first migration has already been applied, since your tables are already there.
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.
I believe I could figure out a solution. I had several projects in my solution.
My database logic was in SqlDataAccess. The assembly was reference in WebUI.
I started off at the DomainLogic. Define POCOs for repository base classes there.
Then I added SqlDataAccess project.
and tried Enable-Migrations, Add-Migration
and Update-Database
command. It ran fine. After I added WebUI (an MVC 4 based web application to the project and ran the commands above. I started getting this version error.
I unload the project WebUI
and re ran the command. And it ran fine again. So, Even if it's not the best solution you might want to unload other projects leaving the atabase project in the solution and then running these commands. It worked for me. All the best!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With