在我的项目中,我有一个派生自另一个 DbContext 的 DbContext。
public class BaseContext : DbContext
{
public DbSet<SomeEntity> SomeEntity { get; set; }
}
public class DerivedContext : BaseContext
{
public class DbSet<SomeOtherEntity> OtherEntity { get; set; }
}
现在我正在编写一个单元测试,其中使用派生上下文的 Sqlite InMemory 版本。在测试中,我使用 EnsureDeleted 和 EnsureCreated 来应用迁移并为我的上下文创建表。如果我对派生上下文执行此操作,则只有在派生上下文中显式定义的表才会通过迁移创建。我必须做什么才能迁移也从基本上下文创建所有表?