ADO.NET entity data model (.edmx) in ASP.NET MVC core 1.0

南楼画角 提交于 2019-11-27 07:31:17

问题


I have couple of questions regarding how to use ADO.NET entity data model (.edmx) in ASP.NET MVC core 1.0 application-

  1. As we are migrating application from MVC 5 to MVC core 1.0, how do we migrate .edmx from MVC5 application developed in VS2013 to MVC core 1.0 new VS2015?

  2. How do I create new ADO.NET entity data model (.edmx) using Database First approach in MVC core 1.0 application in VS2015? [I have already tried creating POCO model and then use scaffold migration command, but want to understand using old wizard approach]


回答1:


ADO.NET entity data model (.edmx) is not supported in Entity Framework Core. Microsoft explained here how to port it.




回答2:


The closest you can come to porting is to create the model in another project,then copy those files into your .NET core application. This will only work if you have chosen a core application that references the previous Frameworks (4.61, 4.52, etc.) When you copy in the EDMX and associated files, you must make sure that they go into the same project as the .Net core application. (If you reference from another project, you will encounter Visual Studio build errors saying that the EntityFramework.dll can't be accessed. ). After copying in the files, add in EntityFramework from Nuget to fix your dbContext and DbSet references. Here is a good article about how to set up the dependency injection in .Net core for EF6:Tony Sneed Blog




回答3:


As the other answers have alluded to, there is no support for EDMX. You will need to regenerate your ED models from the data using the new dotnet scaffold command line utility. You can also use that command to scaffold incremental changes to the database.

Check out the documentation for "dotnet" (you might also be interested in migrations` once you move away from EDMX).

Scaffold Command Documentation



来源:https://stackoverflow.com/questions/38684368/ado-net-entity-data-model-edmx-in-asp-net-mvc-core-1-0

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