.NetCore踩过的坑记录(2):使用EF-orm Core连接MySql数据库

姜还是老的辣

.netCore使用eform连接mysql数据库的方式

引入如下两个包

.NetCore踩过的坑记录(2):使用EF-orm Core连接MySql数据库_第1张图片
Paste_Image.png
特别注意:在目前的情况下
MySql.Data.EntityFrameworkCore 请务必使用6.10.1-beta版
.NetCore踩过的坑记录(2):使用EF-orm Core连接MySql数据库_第2张图片
Paste_Image.png
老规矩 安装1.0版本

新建一个userContext:DbContext

.NetCore踩过的坑记录(2):使用EF-orm Core连接MySql数据库_第3张图片
Paste_Image.png

实体对象User类 需要跟数据库的表里的字段一一对应。

简单的增 查方法如下

.NetCore踩过的坑记录(2):使用EF-orm Core连接MySql数据库_第4张图片
Paste_Image.png

前方高能
那么问题来了 坑点在哪?

坑点我已经帮你们绕开了。

.NetCore踩过的坑记录(2):使用EF-orm Core连接MySql数据库_第5张图片

当然:如果你碰到下面的问题。


.NetCore踩过的坑记录(2):使用EF-orm Core连接MySql数据库_第6张图片
Paste_Image.png

特别注意:在目前的情况下
MySql.Data.EntityFrameworkCore 请务必使用6.10.1-beta版
只要不用最新版就好。

你可能感兴趣的:(.NetCore踩过的坑记录(2):使用EF-orm Core连接MySql数据库)