Error: Your startup project doesn’t reference Microsoft.EntityFrameworkCore.Design

Issue Description

While running EFCore commands like Scaffold-DbContext or Add-Migration etc. application throws below error,

Your startup project ‘ your project’ doesn’t reference Microsoft.EntityFrameworkCore.Design. This package is required for the Entity Framework Core Tools to work. Ensure your startup project is correct, install the package, and try again.

Your startup project doesn't reference Microsoft.EntityFrameworkCore.Design

The error is most visible when running EFCore commands using PMC in Visual Studio but might also exist even using efcore global commands.

Resolution

This error I found to be due to the EFCore not able to decide on which project the Scaffolding needs to be run when you have multiple projects within the solution. Especially when you have Multilayer projects like APILayer, BusinessLayer, or DataAccessLayer.

Step 1: Set your Target project as Startup Project

If your solution has multiple projects then before running EFCore commands please make sure to set your target project (basically the project which will be containing your DBContext) as the StartUp project.

Your startup project doesn't reference Microsoft.EntityFrameworkCore.Design

Step 2- Running the command from PMC

Please make sure to select the project as default within the Package manager console PMC also.

Your startup project doesn't reference Microsoft.EntityFrameworkCore.Design

Once after running the commands for the right module i.e DataLayer(In my case EmployeeService layer), I see the issue got fixed.

Reference:

That’s all! Happy coding!

Does this help you fix your issue?

Do you have any better solutions or suggestions? Please sound off your comments below.



Please bookmark this page and share it with your friends. Please Subscribe to the blog to receive notifications on freshly published(2024) best practices and guidelines for software design and development.



12 thoughts on “Your startup project doesn’t reference Microsoft.EntityFrameworkCore.Design

  1. Hi, my name is Charles, i had this same problem and i found out that the cause was that i installed Misoft.EntityFrameworkCore, Misoft.EntityFrameworkCore.SqlServer and Misoft.EntityFrameworkCore.Tools all in my Data Layer (in one project), remember we have multiple projects (Multiple Tier), and i set one of the projects as the StartUp.
    So my solution was to uninstall Misoft.EntityFrameworkCore.SqlServer and Misoft.EntityFrameworkCore.Tools from the Data layer (that is the project where i have my DbContext) and install them (Misoft.EntityFrameworkCore.SqlServer and Misoft.EntityFrameworkCore.Tools) in the Dependencies of StartUp project.

    HOW TO INSTALL
    Right click on the Dependencies in the StartUp project, select:
    Manage NuGet Packages..
    click install and search the above two packages.
    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *