Cra*_* W. 8 c# entity-framework-6
我们从应用程序中运行迁移,以便即时创建数据库.我们还在单元/集成测试中使用迁移来为要使用的测试创建数据库.几个月前,我们注意到我们测试的运行时间大大增加,我们已经能够将其缩小到DbMigrator类的实例化.即使有一个非常简单的Configuration类,它仍然需要大约10秒钟来创建DbMigrator.
例如,这是从"弹性数据库工具 - 实体框架"示例应用程序中获取的配置类.
internal sealed class Configuration : DbMigrationsConfiguration<ElasticScaleContext<int>>
{
public Configuration()
{
this.AutomaticMigrationsEnabled = false;
this.ContextKey = "CodeFirstNewDatabaseSample.BloggingContext";
}
}
Run Code Online (Sandbox Code Playgroud)
以下是用于创建和运行迁移的代码.
var configurator = new Configuration();
configurator.TargetDatabase = new DbConnectionInfo(connStrBldr.ConnectionString, "System.Data.SqlClient");
var migrator = new DbMigrator(configurator);
migrator.Update();
Run Code Online (Sandbox Code Playgroud)
这是来自VS2015的跟踪信息.
ConfigurationTargetDatabase属性了DbMigrator我们正在使用Entity Framework 6.1.3.还有其他人经历过这个吗?