Where is the EDMX

23,964

Solution 1

There is no edmx support in Entity Framework Core. It only supports a code-first approach. The option to add a new Entity Data Model will be added, but it will produce entity class files instead of an edmx file. The tooling development is a little bit behind the framework development currently.

Solution 2

Still no EDMX support yet for .Net core. To generate the dbcontext and entities from database, run below command in package manager console:

Scaffold-DbContext "Server=yourserver;Database=yourdatabase;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models

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

You will need these packages:

Microsoft.EntityFrameworkCore.SqlServer
Microsoft.EntityFrameworkCore.Tools
Microsoft.EntityFrameworkCore.SqlServer.Design

https://ef.readthedocs.io/en/staging/platforms/aspnetcore/existing-db.html#install-entity-framework

Solution 3

You can take advantage of edmx in dot net core, but only as a reference in order to create the classes that you need.

To do so, you have to add to your solution a project targeting dot net framework 3.5 or higher in order for edmx to work, add an existing edmx file from another, older project because visual studio 2019 does not have that template available, now you can clean it and add entities from sql server.

In the others dot net core project, you have to add t4 templates file .tt these files are going to read the edmx file through the file system path. You have to edit the .tt files in order to work with dot net core.

Once again, you don't need to reference the dot net framework project, it only exists so edmx can work.

Solution 4

As an alternative to an EDMX, there is an open-source extension available to do visual modeling and generate code-first EF contexts and classes. It can consume both a compiled assembly containing a DbContext as well as existing entity class C# code to facilitate bootstrapping the model. Available at:

https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner https://github.com/msawczyn/EFDesigner

Full disclosure: I'm the original author and maintainer.

Share:
23,964
barrypicker
Author by

barrypicker

Technologist with a passion for live music, and things that burn gasoline to go fast.

Updated on October 20, 2020

Comments

  • barrypicker
    barrypicker over 3 years

    Getting exposed to dotnet Core. In a sample test application trying to setup EntityFramework.Core in dotnet core app. While I was able to add the EntityFramework.Core NugGet package I can't find the 'Add'->'New Item'->'Data'->'ADO.NET Entity Data Model'

    Is this not possible with EntityFramework.Core?

    How does EntityFramework.Core differ from EntityFramework 7?