1.Nuget卸载microsoft.entityframeworkcore.design

2.Nuget卸载microsoft.entityframeworkcore.sqlserver

3.Nuget卸载microsoft.entityframeworkcore.sqlserver.design.

4.Nuget安装pomelo.entityframeworkcore.mysql.design

5.Nuget安装pomelo.entityframeworkcore.mysql

6.在解决方案的EntityFrameCore层找到DbContextOptionsConfigurer文件,并做如下修改:

7.在xxx.xxx.Web层安装microsoft.entityframeworkcore.design.

8.更改数据库连接.

9.添加MySQL数据库中表对应的实体对象.

10.执行Migration:Add-Migration InitTable

11.在执行Migration:update-database

看到Done.就代表执行成功.
MySQL中查看,已经成功生成了表.

若过程中有如下报错情况:
执行Migration报错:System.TypeLoadException
HResult=0x80131522
Message=Method 'get_Info' in type 'MySql.Data.EntityFrameworkCore.Infraestructure.MySQLOptionsExtension'
Culture=neutral, PublicKeyToken=c5687fc88969c44d' does not have an implementation.

解决办法:
Nuget更新:pomelo.entityframeworkcore.mysql 版本为3.0.0

执行Migration报错:

解决办法:是因为MySQL的数据库链接配置错误.如截图所示:
要将Server 改为Data Source