我有2个DbContexts:ASP.NET核心多的DbContext不能添加迁移
services.AddDbContext<ConfigDbContext>(options => options.UseSqlServer(Configuration["Data:ConfigSQLServer:ConnectionString"].ToString(), t => t.MigrationsAssembly("App.Web")));
services.AddDbContext<AppDbContext>(options => options.UseSqlServer(Configuration["Data:AppSQLServer:ConnectionString"].ToString(), t => t.MigrationsAssembly("App.Web")));
,当我尝试运行
dotnet ef migrations add Initial -c AppDbContext
我得到:
No DbContext named 'AppDbContext' was found
如果我运行:
dotnet ef dbcontext list
结果是:
FullNamespace.ConfigDbContext
它不缝找到第二的DbContext AppDbContext
ConfigDbCOntext:
public class ConfigDbContext : DbContext
{
public ConfigDbContext()
{
}
public ConfigDbContext(DbContextOptions<ConfigDbContext> options) : base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
}
}
AppDbContext:
public class AppDbContext : IdentityDbContext<ApplicationUser, ApplicationRole, Guid>
{
public AppDbContext()
{
}
public ConfigDbContext(DbContextOptions<AppDbContext> options) : base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
}
}
我做一个编辑对我的问题 – user2818430
废话...如果你切换周围的秩序,它只能找到的第一个? – JanivZ