数据库
首页 > 数据库> > vs2019 C#使用ef自动根据MySql数据库生成实体类

vs2019 C#使用ef自动根据MySql数据库生成实体类

作者:互联网

 

1.vs中下载程序包

Microsoft.EntityFrameworkCore.Tools

Pomelo.EntityFrameworkCore.MySql

 打开 VS2019 "工具" -> "Nuget包管理器" ->"程序包器管理控制台"

 

 在PM光标下输入命令: 

PM> Install-Package Microsoft.EntityFrameworkCore.Tools
PM> Install-Package Pomelo.EntityFrameworkCore.MySql

 

 

 把Mysql数据库转为C#实体的命令

scaffold-dbcontext  -provider Pomelo.EntityFrameworkCore.MySql -connection "Server=xxx.xxx.com;port=58892;Database=MySqlDBTest;uid=root;pwd=12345@abcdf;" -outputdir DBmodels

自动生成DBmodels目录,并且每个表对应一个Class

参考: .net使用ef自动根据数据库生成实体类_malingyu的专栏-CSDN博客1.vs中下载程序包Microsoft.EntityFrameworkCore.ToolsPomelo.EntityFrameworkCore.MySql2.程序中,进入程序包控制台,输入如下命令scaffold-dbcontext -provider Pomelo.EntityFrameworkCore.MySql -connection "Server=*.*.*.*;User...https://blog.csdn.net/malingyu/article/details/103974429?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163263063216780274182028%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=163263063216780274182028&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_v2~rank_v29-4-103974429.pc_v2_rank_blog_default&utm_term=C%23+++mysql+++%E8%A1%A8%E7%BB%93%E6%9E%84++%E8%BD%AC%E6%8D%A2%E5%AE%9E%E4%BD%93%E7%B1%BB&spm=1018.2226.3001.4450

标签:Pomelo,实体类,C#,2522%,ef,程序包,blog,EntityFrameworkCore,MySql
来源: https://blog.csdn.net/majian/article/details/120488731