Oct 30, 2013 at 4:04 PM
Edited Oct 30, 2013 at 4:31 PM
When I wire this up I get the following exception:
An exception of type 'System.InvalidOperationException' occurred in EntityFramework.dll but was not handled in user code
Additional information: The default DbConfiguration instance was used by the Entity Framework before the 'ContextConfiguration' type was discovered. An instance of 'ContextConfiguration' must be set at application start before using any Entity Framework features
or must be registered in the application's config file. See
for more information.
I have two DbContext classes both pointing to the same DB using EF6. One for Security ApplicationDbContext, and the other just handles regular back office types ClientManagementContext. They are in two different class libraries. In the library with ClientMangementContext,
I have a ContextConfiguration class that handles my SqlAzureExecutionStrategy (retry logic).
When I new up my ApplicationDbContext from a bootstrapper class in my MVC application (your code example), am I somehow telling EF to use the default DbConfiguration instead of the ContextConfiguration?
I don't have a ContextConfiguration in the class library where my ApplicationDbContext lives, so when S.I. gets to newing up ClientManagmentContext (where ContextConfiguration lives), SI has already build the Default Configuration because of the newing up of
To test, when I removed my ContextConfiguration from my ClientManagmentContext class library, then at least the application starts and the exception was not thrown. I'll need to test to see the two contexts actually work as they had before. Also, by taking
out the ContextConfiguration, I no longer have a Azure DB retry strategy.
Also, before I added the ApplicationDbContext, the ClientManagmentContext with ContextConfiguration and S.I. seemed to work (no exceptions thrown and I was able to query/write at will to the db). But I had not fully tested the Azure retry logic.
I'll add to this post when I'm sure the two contexts work.
I can supply code if you like.