我使用Code First EF使用breeze。我的产品DbContext有IDatabaseInitializer,如果!context.Database.CompatibleWithModel(true)
引发异常。如果我创建了如the documentation中建议的上下文,则无法检查数据库兼容性。如何使用ContextProvider.EntityConnection创建辅助DbContext?
// The following line will throw NotSupportedException.
// Unable to verify the compatibility of the model because
// the DbContext instance was not created using Code First patterns.
var context2 = new MyDbContext(EntityConnection, false); // create a DbContext using the existing connection
我应该如何实例化提供ContextProvider的EntityConnection的DbContexts?
不,事实并非如此。 MyDbContext使用Code First构建模型。一切工作正常,当我创建它只传递连接字符串或使用默认的ctr。 'var context2 = new MyDbContext();' – pawel
DOCU中的部分创建ObjectContext/DbContext动态? –
@ phil-soady按照我提供的链接向下滚动到“用于BeforeSaveEntities和AfterSaveEntities的ContextProvider方法”http://www.breezejs.com/documentation/custom-efcontextprovider#ContextProvidermethods。 – pawel