简体   繁体   English

使用实体数据模型 EF CORE 6

[英]Using Entity Data model EF CORE 6

i'm try migrate an application from .net 4.7 to .net core 6.我正在尝试将应用程序从 .net 4.7 迁移到 .net core 6。

i installed visual studio 2022 with net core 6 sdk, then create a class library and install EF Core from nugget.我用 net core 6 sdk 安装了 Visual Studio 2022,然后创建一个类库并从 nugget 安装 EF Core。

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.现在,想使用“ADO.NET 实体数据模型”创建我的类模型,就像在 .net framework 4.7 中一样,从现有的 BD 创建模型。

my class library dependences:我的类库依赖项:

在此处输入图像描述

DataModel creation:数据模型创建:

在此处输入图像描述

But it throws me the following error.但这给我带来了以下错误。

在此处输入图像描述

在此处输入图像描述

I don't understand the problem since I have .NET Core 6 installed with its sdk.我不明白这个问题,因为我安装了 .NET Core 6 及其 sdk。 What other dependency would I be missing?我会缺少什么其他依赖项?

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如果您想从数据库生成模型和上下文,您需要使用可用的工具、 cliPMC使用 ef 核心脚手架

Reverse engineering is the process of scaffolding entity type classes and a DbContext class based on a database schema.逆向工程是基于数据库模式构建实体类型类和 DbContext 类的过程。 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.它可以使用 EF Core 包管理器控制台 (PMC) 工具的 Scaffold-DbContext 命令或 .NET 命令行界面 (CLI) 工具的 dotnet ef dbcontext scaffold 命令执行。

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. .NET 6.0 不支持您可以将目标框架更改为 .NET 框架 4.8 另一种选择是使用存储库模式并跳过使用 EF 数据模式。

I hope this would help.我希望这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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