Home > Net >  Using Entity Data model EF CORE 6
Using Entity Data model EF CORE 6

Time:06-25

i'm try migrate an application from .net 4.7 to .net core 6.

i installed visual studio 2022 with net core 6 sdk, then create a class library and install EF Core from nugget.

Now, want to create my class model using "ADO.NET Entity Data Model " like in .net framework 4.7 for create model from existing BD.

my class library dependences:

enter image description here

DataModel creation:

enter image description here

But it throws me the following error.

enter image description here

enter image description here

I don't understand the problem since I have .NET Core 6 installed with its sdk. What other dependency would I be missing?

CodePudding user response:

If you want to generate your model and context from the db you need to use ef core scaffolding using the tools available, cli or PMC

Reverse engineering is the process of scaffolding entity type classes and a DbContext class based on a database schema. It can be performed using the Scaffold-DbContext command of the EF Core Package Manager Console (PMC) tools or the dotnet ef dbcontext scaffold command of the .NET Command-line Interface (CLI) tools.

CodePudding user response:

It is not supported with .NET 6.0 You can change the target framework to .NET framework 4.8 Another option is to use Repository pattern and skip using EF data modal.

I hope this would help.

  • Related