我想在我的项目中从 MigrateDatabaseToLatestVersion 派生一个类。
public abstract class BaseDatabaseInitializer<TContext> : MigrateDatabaseToLatestVersion<TContext, MigrationConfiguration>
where TContext : DbContext
MigrationConfiguration 类看起来像这样
internal sealed class MigrationConfiguration : DbMigrationsConfiguration<QAdminDbContext>
{
public MigrationConfiguration()
{
AutomaticMigrationsEnabled = true;
}
protected override void Seed(QAdminDbContext context)
{
// This method will be called after migrating to the latest version.
// You can use the DbSet<T>.AddOrUpdate() helper extension method
// to avoid creating duplicate seed data. E.g.
//
// context.People.AddOrUpdate(
// p => p.FullName,
// new Person { FullName = "Andrew Peters" },
// new Person { FullName = "Brice Lambson" },
// new Person { FullName = "Rowan Miller" }
// );
//
}
}
但我不允许这样做并且出现错误
"Inconsistent accessibility: base class 'System.Data.Entity.MigrateDatabaseToLatestVersion<TContext,Lutron.Application.QAdmin.Database.EntityConfiguration.MigrationConfiguration>' is less accessible than class 'Lutron.Application.QAdmin.Database.BaseDatabaseInitializer<TContext>' E:\Proj\Lutron\Code\src\Lutron\Gulliver\QAdmin\DataAccess\Database\BaseDatabaseInitializer.cs 17 27 Database"
这是因为 MigrateDatabaseToLatestVerion 类明确定义了 MigrationConfigurationContext 的 where 子句。
因为,在我的自定义类中,我已经明确定义了 ' Configuration
' 类,所以我不能添加 where 子句。