I'm using breeze with Code First EF. My production DbContext has IDatabaseInitializer that throws an exception if !context.Database.CompatibleWithModel(true)
. If I create a context like suggested in the documentation database compatibility cannot be checked.
// 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
How should I instantiate DbContexts providing ContextProvider's EntityConnection?
See Question&Answers more detail:os