【发布时间】:2021-09-07 04:47:25
【问题描述】:
我想在我的项目中使用身份。我确实创建了身份DbContext,并且我确实将身份服务添加到了我的启动文件中
但是当我想创建一个新的迁移时,我看到了这个错误:
无法为设计时支持的不同设计模式创建上下文名称类型的对象
我的上下文代码在这里:
public class websitecontext : IdentityDbContext
{
public websitecontext(DbContextOptions<websitecontext> options) : base(options)
{
}
}
我的启动代码在这里
services.AddDbContext<websitecontext>(s =>
s.UseSqlServer(Configuration.GetConnectionString("websiteconnectionstring"))
);
services.AddIdentity<IdentityUser, IdentityRole>()
.AddEntityFrameworkStores<websitecontext>()
.AddDefaultTokenProviders();
请帮助我,我在 google 中搜索过,但没有找到任何结果
【问题讨论】:
-
您能否显示您的注册身份代码以及您如何定义您的应用程序 dbContext ?
-
在这里分享你的相关代码。
-
让我编辑我的问题...
-
我在问题中添加了上下文代码
-
您使用软件包控制台还是普通 CLI?任何一个人都必须知道您的 Startup 项目。
标签: c# .net asp.net-core .net-core