EFCore Migration ERROR in different Project 报错

EFCore Migration ERROR in different Project Error

我的DbContext(XQTContext)位置在XQT.Core.Repository。 我的 Web 应用程序 nuget Microsoft.EntityFrameworkCore.Tools、Microsoft.EntityFrameworkCore.Design。 packages 是 5.0.13

在startup.cs services.AddDbContext( options => options.UseSqlServer(_configuration.GetConnectionString("DefaultConnection"), b => b.MigrationsAssembly("XQT.Core")) );

注意:XQT.Core 中的控制台 我执行 Add-Migration Init -Project XQT.Core.Repository,但错误是

An error occurred while accessing the Microsoft.Extensions.Hosting services. Continuing without the application service provider. Error: An error occurred while updating the entries. See the inner exception for details. Unable to create an object of type 'XQTContext'. For the different patterns supported at design time,

谢谢

也许这就是您正在寻找解决方案的问题。