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

Dung Do Tien Feb 24 2022 300

Hello Guys, I created a project using Asp.net core 3.1 and Entity framework core 3.1 database first.

I have two projects :

 Test.GoogleNotification (sln)
--- Test.GoogleNotification.Dal (Data access layer)
--- Test.GoogleNotification.App (web app)

To use entity framework core,  I installed 3 packages below inside Test.GoogleNotification.Dal project:

 Microsoft.EntityFrameworkCore.Design (v 3.1.22)
Microsoft.EntityFrameworkCore.SqlServer (v 3.1.22)
Microsoft.EntityFrameworkCore.Tools (v 3.1.22)

After then I open Package Manager Console to run the command below to help generate FE core:

 PM> Scaffold-DbContext "Server=DESKTOP-9HHLK4D;Database=GoogleNotification;user id=sa;[email protected];Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models

But I got an error Your startup project doesn't reference Microsoft.EntityFrameworkCore.Design.

 PM> Scaffold-DbContext "Server=DESKTOP-9HHLK4D;Database=GoogleNotification;user id=sa;[email protected];Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
Build started...
Build succeeded.
Your startup project 'Test.GoogleNotification.App' 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.
PM> 

I chose the default project combobox is Test.GoogleNotification.Dal but I don't know why it throws an error in the project Test.GoogleNotification.App.

How can I fix it?

Have 2 answer(s) found.
  • L

    Lester Laban Laban Feb 24 2022

    You can re-check what is the current startup project? it is Test.GoogleNotification.App, right? You have to set it to Test.GoogleNotification.Dal and it will be solved for you.

  • ר

    ראובן בן סימון Feb 24 2022

    You can install Microsoft.EntityFrameworkCore.Design package for that project (Test.GoogleNotification.App) by using the command below:

      Install-Package Microsoft.EntityFrameworkCore.Design -Version <version>

    <version> : You can see all versions here https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Design/

    If you installed it but it still throws the same error, maybe you need to build the project and try again.

Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips

X Close