简体   繁体   中英

How to create an Entity Framework edmx file for an existing database with .NET Standard and Entity Framework Core?

In the past, I've been using .NET Framework 4.6 with Entity Framework 6 to generate an edmx file and the associated model files. For one of my projects, I'd like to switch to ASP.NET Core MVC as front end and, therefore, want to change my DAL from .NET Framework 4.6 and EF 6 to .NET Standard 2.

Since the project files were initially created with VS 2012, they still use the old syntax and I somehow can't change the target framework via Visual Studio itself. I've read that is probably easier to just recreate the project with Visual Studio 2017 and target .NET Standard 2 and just step-by-step insert the old code. The first thing that I want to recreate is my Entity Framework mapping with a DBContext. So far, I've added some EF Core dependencies from NuGet, but I fail to create an edmx file that is comparable to what I'm used to from .NET Framework 4.6. Visual Studio does not seem to offer a specific wizard for that in 'add new file'.

What am I missing here? So far, I've checked some previous Stackoverflow posts (such as Trying to set-up Entity Framework core in .Net Standard project ) and multiple Udemy courses, but I still don't understand how I can use an equivalent of EF 6 (eg, an edmx file) in .NET Standard.

Per Microsoft:

"EF Core does not support the EDMX file format for models. The best option to port these models, is to generate a new code-based model from the database for your application."

https://docs.microsoft.com/en-us/ef/efcore-and-ef6/porting/port-edmx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM