Entity Framework Core Add-Migration cannot execute

.net entity-framework entity-framework-core


I'm trying to to set up a new database/migrations with Entity Framework Core (version 1.1.0) on a .NET application.

PM> Add-Migration InitialMigration
Cannot execute this command because Microsoft.EntityFrameworkCore.Design is not installed. Install the version of that package that matches the installed version of Microsoft.EntityFrameworkCore and try again.

I have already installed Microsoft.EntityFrameworkCore.Design (along with Tools (version 1.1.0-preview4-final), and the Relational/Relational.Design and Sqlite packages). I can see this in the Nuget package manager.

Now this does seem similar to this Q&A - Entity Framework Core 1.0.1 add-migration - but there's a few differences, mainly there is no project.json anywhere, and the error message is slightly different.

There is a packages.config file which has this in it.

  <package id="Microsoft.EntityFrameworkCore" version="1.1.0" targetFramework="net46" />
  <package id="Microsoft.EntityFrameworkCore.Design" version="1.1.0" targetFramework="net46" />
  <package id="Microsoft.EntityFrameworkCore.Relational" version="1.1.0" targetFramework="net46" />
  <package id="Microsoft.EntityFrameworkCore.Relational.Design" version="1.1.0" targetFramework="net46" />
  <package id="Microsoft.EntityFrameworkCore.Sqlite" version="1.1.0" targetFramework="net46" />
  <package id="Microsoft.EntityFrameworkCore.Tools" version="1.1.0-preview4-final" targetFramework="net46" developmentDependency="true" />
5/23/2017 12:08:44 PM

Accepted Answer

I had to install the Microsoft.EntityFrameworkCore.Design package in not only the class library that implemented the DbContext class, but also in the project (in this case the GUI/WinForms project) that referenced said class library. This was despite having selected the class library in the Package Manager Console as user Derek suggested.

Once I did this I was able to run the Add-Migration command and related commands.

12/6/2016 3:19:17 PM

Popular Answer

Make sure that you have the project selected in the package manager console that has EntityFramework Installed.

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