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.
10.执行Migration:Add-Migration InitTable
![](https://img.haomeiwen.com/i10254515/d1babe995d4560c3.png)
11.在执行Migration:update-database
![](https://img.haomeiwen.com/i10254515/f7100e41ced2de03.png)
看到Done.就代表执行成功.
MySQL中查看,已经成功生成了表.
![](https://img.haomeiwen.com/i10254515/f48ebb926970ca4e.png)
执行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
解决办法:是因为MySQL的数据库链接配置错误.如截图所示:
要将Server 改为Data Source
如截图所示:
给大家推荐一个面试神器,帮助大家升职,加薪,跳槽,刷面试题的小程序.
面试一点通丨模拟面试 模拟笔试 收录全网面试真题,助你跳槽成功
![](https://img.haomeiwen.com/i10254515/fd70caf59e0fdbd2.png)
网友评论