在项目三中,我有 ProjectOneDBContext 和 ProjectTwoDBContext 指向两个网络的相同数据库应用程序在一起。我在处理相同的迁移程序集和并具有通用身份表
时遇到问题在 ProjectOne的Startup.cs 中:
services.AddDbContext<ProjectOneDBContext>(options =>
options.UseSqlServer(
databaseConnectionString,
o => o.MigrationsAssembly(projectThreeMigrationAssembly)),
ServiceLifetime.Singleton,
ServiceLifetime.Singleton);
在 ProjectTwo的Startup.cs 中:
services.AddDbContext<ProjectTwoDBContext>(options =>
options.UseSqlServer(
databaseConnectionString,
o => o.MigrationsAssembly(projectThreeMigrationAssembly)),
ServiceLifetime.Singleton,
ServiceLifetime.Singleton);
ProjectThree中的ProjectOneDBContext.cs
public class ProjectOneDBContext : IdentityDbContext<ApplicationUser>
{
...
public void ConfigureDevelopment(...)
{
...
context.Database.Migrate();
...
}
...
}
ProjectThree中的ProjectTwoDBContext.cs
public class ProjectTwoDBContext : IdentityDbContext<ApplicationUser>
{
...
public void ConfigureDevelopment(...)
{
...
context.Database.Migrate();
...
}
...
}
答案 0 :(得分:0)
ProjectTwoDBContext不必从IdentityDbContext继承,因为ProjectOneDBContext已经继承了它。