How to scaffold EF core to existing DB?
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
Matthew Verstraete
Updated on June 08, 2022Comments
-
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 over 8 yearsI get the same error when I change from ending
EntityFramework
toEntityFramework.MicrosoftSqlServer
The solution does have 3 projects (CORE, DAL, WebUI) and I am in the WebUI project which does haveEntityFramework.Commands
andEntityFramework.MicrosoftSqlServer
in the project.json file -
Matt Sanders over 8 yearsThat reminded me, I also had to add this into my project.json: EntityFramework.MicrosoftSqlServer.Design
-
Matthew Verstraete over 8 yearsAdding that to the project.json fixed it. Thanks
-
Zack Tarr about 5 yearsNo luck on this option :(
-
Moji over 4 yearsinstalling EntityFramework.MicrosoftSqlServer.Design did it