1.移除SQL Server的Nuget包

打开程序包管理器控制台,并选中.EntityFrameworkCore

ABP框架中使用MySQL数据库

然后依次执行:

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文件,并做如下修改:

ABP框架中使用MySQL数据库

4.修改数据库连接字符串

在appsetting.json文件中修改数据库连接字符串:

"Default": "Server=localhost;Port=3306;Database=你的数据库名;Uid=数据库用户名;Pwd=密码;"

5.添加数据迁移

删除EntityFrameCore层中Migrations文件夹里的所有文件,别删除Migrations文件夹,然后重新生成解决方案,接着打开程序包管理器控制台,选中.EntityFrameworkCore,输入以下命令:

Add-Migration Init

此时你的Migrations文件夹里会新增几个文件,接着输入命令:

Update-Database

ABP框架中使用MySQL数据库

数据库更新成功

 

相关文章:

  • 2021-10-15
  • 2021-06-23
  • 2021-12-18
  • 2022-12-23
  • 2021-10-28
  • 2022-01-15
  • 2022-12-23
猜你喜欢
  • 2021-07-11
  • 2022-01-28
  • 2022-12-23
  • 2021-10-01
  • 2021-11-21
  • 2022-12-23
相关资源
相似解决方案