Picking up one of our projects after a few weeks, I ran into following error:
Add-Migration : Exception calling "CreateInstanceAndUnwrap" with "8" argument(s): "Could not load file or assembly 'Microsoft.EntityFrameworkCore.Design.Core, Version=220.127.116.11, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified." At line:1 char:1 + Add-Migration InitialSetup + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Add-Migration], MethodInvocationException + FullyQualifiedErrorId : FileNotFoundException,Add-Migration
I first thought this had to do with the updated Microsoft.EntityFrameworkCore.Sqlite package. But digging up my sample from a previous post, I received the same error. Which was weird, as everything worked before and I didn’t upgrade any packages there. Crawling through search results, we found this issue from Dave Smits. So I carefully followed all steps (without luck):
- Mark the app as startup project
- Set the default project to my class library
- Add the app.config file
Bonus: if Add-Migration is not recognized: build your solution (or simply restore the NuGet packages) and restart Visual Studio.
The next step was contacting Dave on Skype to double check the steps and let him try to create migrations on my sample app. And right when he said it worked on his machine, I noticed the problem: UWP apps can’t run in the AnyCPU configuration. When you check the build configurations, building your app is even unchecked in this configuration. You need to select x86, x64 or ARM. Guess which configuration was selected by default when opening my project.
Simply switch to x86 and you’ll be able to add your migrations again. Hopefully you won’t loose as much time on this dumb mistake (which are the toughest ones to crack) as I did.