无法添加迁移:system.invalidoperationException:无法解析类型的服务' Microsoft.entityframeworkcore.dbcontextoptions'
尝试为我的.NET Core 6.0项目添加迁移时,我会收到以下错误: 在类“程序”上没有找到静态方法“ Create -HostBuilder(String [])'。 找不到应用服务提供商。 在项目中查找DBContext类... 找到dbContext'applicationdbContext'。 Microsoft.EntityFrameWorkCore.Design.OperationException:无法创建类型“ ApplicationDbContext”的对象。有关设计时间支持的不同模式,请参见 https://go.microsoft.com/microsoft.com/fwlink /?linkID = 851728 ---> system.invalidoperationException:无法解析“ Microsoft.entityFrameWorkCore.dbContextOptions”类型的服务,同时尝试激活'dataAccess.data.applicationdbcontext'。
我的项目结构看起来像这样: 在此处输入图像描述
使用我的dataAcess项目,包含我的代码第一个结构,我的applicationdbcontext代码是:
public class ApplicationDbContext : IdentityDbContext<IdentityUser>
{
public ApplicationDbContext(DbContextOptions options)
: base(options)
{
}
public ApplicationDbContext() { }
public DbSet<Attachment> Attachments { get; set; }
public DbSet<Column> Columns { get; set; }
public DbSet<DevopsBoard> DevopsBoards { get; set; }
public DbSet<DevopsBug> DevopsBugs { get; set; }
public DbSet<Priority> Priorities { get; set; }
public DbSet<Project> Projects { get; set; }
public DbSet<Severity> Severities { get; set; }
}
i在EF CLI中尝试了以下选项: 添加迁移第一个-startupproject dataAccess -verbose
add -Orgration首先-Project issuemaster -startupproject dataAccess -Verbose
可以给我一些指导吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对我的情况有用的是,我已将Microsoft.EntityFrameWorkCore.Design添加到我的启动项目和Microsoft.entityframeworkcore, *工具和 *sqlserver和 *SQLServer中
,并且在运行迁移之后
What worked for my case is that I've added Microsoft.EntityFrameworkCore.Design for my startup project and Microsoft.EntityFrameworkCore, *Tool, and *SqlServer have been installed into the Infrastructure project
and after that run the migration