Bootstrap

.Net Core EF遇到的问题笔记

.Net Core EF遇到的问题笔记

记录 .Net Core3.1 + MySQL 实现EF Code First遇到的问题
执行:
dotnet ef migrations add InitialCreate
出现:
No project was found. Change the current working directory or use the --project option.
这时用下面的命令执行:

PM> dotnet ef migrations add InitialCreate  --verbose --project "H:\WebAPI\xxxx.xxxxx.Models"

执行上面的命令出现:
Found DbContext ‘MyDbContext’.
Microsoft.EntityFrameworkCore.Design.OperationException: Unable to create an object of type ‘MyDbContext’. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728

再然后在MyDbContext同一个项目下添加

public class MyContextFactory 
;