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?
If you need to re-scaffold the model after database schema changes have been made, you can do so by specifying the -f or --force option e.g.: dotnet ef dbcontext scaffold "Server=. \;Database=AdventureWorksLT2012;Trusted_Connection=True;" Microsoft. EntityFrameworkCore.
The above Scaffold-DbContext command creates entity classes for each table in the SchoolDB database and context class (by deriving DbContext ) with Fluent API configurations for all the entities in the Models folder.
Install fallowing NuGet package:
Install-Package Microsoft.EntityFrameworkCore.SqlServer
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With