ABP框架中使用MySQL数据库

1.移除SQL Server的Nuget包
打开程序包管理器控制台,并选中.EntityFrameworkCore
 
然后依次执行:
uninstall-package microsoft.entityframeworkcore.design
 
uninstall-package microsoft.entityframeworkcore.sqlserver
2.安装MySQL的Nuget包
依次执行:
install-package pomelo.entityframeworkcore.mysql.design
 
install-package pomelo.entityframeworkcore.mysql
3.更改配置文件
在解决方案的EntityFrameCore层找到DbContextConfigurer文件,并做如下修改:
 
4.修改数据库连接字符串
在appsetting.json文件中修改数据库连接字符串:
"Default": "Server=localhost;Port=3306;Database=你的数据库名;Uid=数据库用户名;Pwd=密码;"
5.添加数据迁移
删除EntityFrameCore层中Migrations文件夹里的所有文件,别删除Migrations文件夹,然后重新生成解决方案,接着打开程序包管理器控制台,选中.EntityFrameworkCore,输入以下命令:
Add-Migration Init
此时你的Migrations文件夹里会新增几个文件,接着输入命令:
Update-Database

数据库更新成功
————————————————
版权声明:本文为CSDN博主「undefined^」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/tangmou_ren/article/details/84856892

猜你喜欢

转载自www.cnblogs.com/WebApp-DotNet/p/12190323.html