2
votes

First of all, all other questions here with this problem are for ASP.NET Core projects, and the solution is to add the Microsoft.EntityFrameworkCore.Design to the tools section on project.json, but... I'm not using ASP.NET Core, so I don't have project.json in my project. So please keep it in mind before marking it as duplicate since I saw that's a fairly common question...

When I type add-migration InitialMigration on Package Manager Console I get the following error:

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.

But as you can see on the image bellow, it is installed on this project:

enter image description here

My database layer is in a separated project, which is Full Framework ClassLibrary, and because of this I don't have a projec.json file.

Does anyone tried to use migrations on class libraries projects?

1
Is the data context in the highlighted project? If not, then you need to select the project with the data context in the drop-down next to "Default Project"Duston
Yes, it's in this project.rbasniak
Should be possible based on this. You have update 3.3 and web tools update?Steve Greene
Yep, it was working os ASP.NET Core projects... I'll try to recreate the solution or reinstall VS =(rbasniak
Check in your project.json : "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final" (for PM Add-Migration) and/or "tools": { "Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0-preview3-final" } for dotnet CLI (dotnet ef migrations add...)kall2sollies

1 Answers

4
votes

In dotnet core this is typically due to the fact that you're missing a package. Go into the NuGet Package Manager on the solution level and install Microsoft.EntityFrameworkCore.Tools for your project.

enter image description here