Can't scaffold with ef core for a console application project, doesnt reference .design package

.net-core entity-framework-core


When using Entity Framework Core for a console application i can't scaffold the database.

dotnet ef dbcontext scaffold "Server=;User Id=;Password=;Database="
"Microsoft.EntityFrameworkCore.SqlServer" -c Context -o Models -t Tables -f

Your startup 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.

I've tried to install both Microsoft.EntityFrameworkCore.Design and Microsoft.EntityFrameworkCore.SqlServer.Design. Same problem.

If i set up a new mvc core application i don't get this error. Only when i set up new console applications.

What am i doing wrong?

4/5/2019 7:17:10 AM

Popular Answer

I ran into a similar problem until I used the Entity Framework Core .NET CLI. Try the following to see if it will work for you:

  • dotnet new console

  • dotnet add package Microsoft.EntityFrameworkCore.SqlServer

  • dotnet add package Microsoft.EntityFrameworkCore.Design

  • dotnet ef -h

You should see the EFC CLI Options screen. Do the following to scaffold (replace connection string with your own):

  • dotnet ef dbcontext scaffold "Server=.\;Database=AdventureWorksLT2012;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -o Model

Once you to that, you should see a Model folder in your project with the class files representing the entities.

5/7/2019 6:32:57 PM

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