プロジェクトで 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 句を追加できません。