实体框架核心从现有数据库创建模型 [英] Entity Framework Core creating model from existing database

查看:111
本文介绍了实体框架核心从现有数据库创建模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Entity Framework Core,如何生成EF模型和实体?

With Entity Framework Core, how do you generate the EF model and the entities?

根据 ASP.NET Core-现有数据库 Microsoft文章,您需要在软件包中运行像这样的命令管理器控制台:

According to ASP.NET Core - Existing Database Microsoft article you need to run a command like this one in the Package Manager Console:

Scaffold-DbContext "Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models

这使您可以零控制要导入的表或视图。是否有可能是现在使用EF Core对数据库进行反向工程和创建EF模型和实体的唯一方法?与多年来使用完整Entity Framework进行的方法相比,进展如何?

That gives you zero control on what tables or views to import. Is it possible that this is the only way to reverse engineer the database and create the EF models and entities now with EF Core and how is that progress when compared to the way this was done with full Entity Framework for years now?

推荐答案

在Entity Framework Core中无法做到这一点。
在此处阅读文档:
https: //docs.microsoft.com/en-us/ef/efcore-and-ef6/features

There's no way to do that in Entity Framework Core. Read the documentation here: https://docs.microsoft.com/en-us/ef/efcore-and-ef6/features

这篇关于实体框架核心从现有数据库创建模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆