enable migration nuget command in VS 2012 for entity framework throw Exception

0 votes
asked Jul 5, 2013 in Visual Studio by anonymous

I was trying to enable database migration using NuGet power shell in Visual studio 2012. But got the following exception. Any suggestion to fix this?

I used the below command
pk> enable-migrations -EnableAutomaticMigrations

Exception calling "CreateInstanceFrom" with "8" argument(s): "Could not load file or assembly 'EntityFramework, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The locate
d assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"
At C:\Users\abc001\Documents\Visual Studio 2012\Projects\SequentialWorkflowDemo\packages\EntityFramework.6.0.0-beta1\tools\EntityFramework.psm1:698 char:31
+ $domain.CreateInstanceFrom <<<< (
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodTargetInvocation


1 Answer

+1 vote
answered Jul 6, 2013 by Aadhira (1,213 points)
selected Jul 8, 2013 by administrator
Best answer

The issue is happening because you might be having multiple versions of entity framework packages used in the project.

Verify your packages.config of the project in which you are getting this error. It may be using entity framework version 6 beta, If so, remove that config entry from the package configuration and also remove the EntityFramework dll reference from the project.

nuget package config screen shot


If you want to use Entity Framework 5.0, then you have to choose the “Stable Only” option when you add EntityFramework reference through Manage NuGet packages as below. If you have chosen the “Include Prerelease” option, then EntityFramework 6 beta version will be added because that is latest version.

So, add a new reference with the “Stable Only” option then try the enable migrations command, it should work fine.


Manage Nuget Package Window Screen Shot



Your answer


Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
site design / logo / content © 2013 - 2015 pinfaq.com