How to scaffold EF core to existing DB?

非 Y 不嫁゛ 提交于 2019-12-11 00:59:30

问题


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?


回答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



回答2:


Install fallowing NuGet package:

Install-Package Microsoft.EntityFrameworkCore.SqlServer



回答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.



来源:https://stackoverflow.com/questions/35301214/how-to-scaffold-ef-core-to-existing-db

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!