How to scaffold EF core to existing DB?

16,772

Solution 1

Make sure you are in the project folder and not the solution folder context. I was able to get this to work with the following yesterday (Notice the EntityFramework.MicrosoftSqlServer at the end)

dnx ef dbcontext scaffold "{connectionString}" EntityFramework.MicrosoftSqlServer

EDIT:

Make sure to include the following in your project.json:

EntityFramework.MicrosoftSqlServer.Design

Solution 2

Install fallowing NuGet package:

Install-Package Microsoft.EntityFrameworkCore.SqlServer

Solution 3

I was getting the following error when trying to scaffold from an existing SQLite database:

Unable to find provider assembly with name Microsoft.EntityFramworkCore.Sqlite. Ensure the specified name is correct and is referenced by the project.

The project was in a solution with one other project. Even though the correct project was referenced in the Package Manager Console it only worked when I selected the 'Set as Startup Project' item on the project context menu.

Solution 4

Close Visual Studio
Delete %temp% folder
Delete .vs folder

dotnet ef dbcontext scaffold "Server=REMOVED;Database=REMOVED;User ID=REMOVED;Password=REMOVED" Microsoft.EntityFrameworkCore.SqlServer
Share:
16,772
Matthew Verstraete
Author by

Matthew Verstraete

Updated on June 08, 2022

Comments

  • Matthew Verstraete
    Matthew Verstraete almost 2 years

    I am trying to reverse engineer an existing database using Entity Framework Core. I tried to follow the directions from Microsoft but I am presented with the error:

    Unable to find provider assembly with name EntityFramework. Ensure the specified name is correct and is referenced by the project.

    I am running the following command from the project directory:

    dnx ef dbcontext scaffold "Server=REMOVED;Database=REMOVED;User ID=REMOVED;Password=REMOVED" EntityFramework
    

    What am I doing wrong?

  • Matthew Verstraete
    Matthew Verstraete over 8 years
    I get the same error when I change from ending EntityFramework to EntityFramework.MicrosoftSqlServer The solution does have 3 projects (CORE, DAL, WebUI) and I am in the WebUI project which does have EntityFramework.Commands and EntityFramework.MicrosoftSqlServer in the project.json file
  • Matt Sanders
    Matt Sanders over 8 years
    That reminded me, I also had to add this into my project.json: EntityFramework.MicrosoftSqlServer.Design
  • Matthew Verstraete
    Matthew Verstraete over 8 years
    Adding that to the project.json fixed it. Thanks
  • Zack Tarr
    Zack Tarr about 5 years
    No luck on this option :(
  • Moji
    Moji over 4 years
    installing EntityFramework.MicrosoftSqlServer.Design did it