I have a problem with migrations api in EntityFramework. My DataContext and Entities contained in dll that have strong name (signed with certificate) and when i deploy my application it places dll in GAC. So when i am using migration commands in Package Manager Console it always using dll from GAC instead of dll in project folder. So to add new migration after model changes i need to deploy dll to GAC, then restart Visual Studio and after this run Add-Migration.
Is there a way to force using of dll from project? i have tried to use AppDomainBaseDirectory parameter with target to Debug folder of project output, but it does not help.
Just an idea, but I wonder if the Package Manager Console will pick up assembly binding redirects in your app.config? May be worth a shot if you haven't got anywhere with this yet.
Just make sure your local and GAC assemblies have different version numbers and put the redirect info in the app.config of your migrations project as per this link: http://msdn.microsoft.com/en-us/library/7wd6ex19(v=vs.110).aspx
GAC has higher priority than locale assembly for the same assembly version, check this article.
To fix your problem, either:
Increase the assembly version either manually or automatically using Build Version Increment Add-In to override loading the GAC
As specified in the link's comment, to install for VS2012.
BuildVersionIncrement.Addin
andBuildVersionIncrement.dll
fromC:\Users\[User]\Documents\Visual Studio 2010\Addins
toC:\Users\[User]\Documents\Visual Studio 2012\Addins
BuildVersionIncrement.Addin
<Version>10.0</Version>
to11.0
Set the assembly versioning style (major, minor, build, revision). for automatic build, revision segment would be sufficient