Add-Migration command not working in EF 7 for UWP app

entity-framework-core sqlite uwp


I'm following getting started with EF 7 for UWP apps official tutorial.

When I'm at Add-Migration MyFirstMigration, it throws following error:

PM> Add-Migration MyFirstMigration

Add-Migration : Exception calling "CreateInstanceAndUnwrap" with "8" argument(s): "Could not load file or assembly 'AppShellProject, Version=, Culture=neutral, PublicKeyToken=null' 
or one of its dependencies. An attempt was made to load a program with an incorrect format."
At line:1 char:1
+ Add-Migration MyFirstMigration
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Add-Migration], MethodInvocationException
    + FullyQualifiedErrorId : BadImageFormatException,Add-Migration

Has anyone figured out any workaround?

10/7/2015 5:34:49 AM

Accepted Answer

Great job @Anil. :)

Actually, since this kind of issue may be related to Visual Studio tools or NuGet. By searching "CreateInstanceAndUnwrap Add-Migration" in EF repository on GitHub, you will see some issues there. If you cannot find any existing issues next time, as same as the questions(project.json, project type and etc. ) I asked, try to find out what's the difference between your steps/configurations and the tutorial will be helpful and you will have more info to get a quick answer.

I believe @bricelam has pointed out the issue you encountered, and no one is more familiar with EF7 than him. I want to pick some key messages from @bricelam in that issue as the ending:

Correct, the Migration commands won't work with x64 assemblies. The current implementation executes inside of an AppDomain created from VS (devenv.exe) which is a 32-bit process.

you'll have to use x86 at design-time.

10/8/2015 3:11:34 AM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow