dotnetcore 连接字符串卸载startup中 无法执行dotnet ef migrations add命令

如题,如果连接字符串写在startup中提示:

System.InvalidOperationException: No database provider has been configured for this DbContext. A provider can be configured by overriding the DbContext.OnConfiguring method or by using AddDbContext on the application service provider. If AddDbContext is used, then also ensure that your DbContext type accepts a DbContextOptions<TContext> object in its constructor and passes it to the base constructor for DbContext.

如果将连接字符串写在 context中是可以执行的.

项目结构图:图片说明

  • 写在StartUp中的截图:图片说明图片说明
  • 写在Context中的截图:图片说明

https://www.cnblogs.com/chonghanyu/p/5709780.html