I have a solution where I want to add another project with it's own DBcontext, using its own tables, in the same database as the rest of the solution (the 2 DBcontexts are not sharing any tables). But when running the project I am getting the error below:
Additional information: The default DbConfiguration instance was used by the Entity Framework before the 'Configuration' type was discovered. An instance of 'Configuration' must be set at application start before using any Entity Framework features or must be registered in the application's config file.
I already have a big database built in the existing solution, so I don't want to change anything there, if I can avoid that. I have tried to change the
ContextKey in the configuration and also tried to use another DB schema for the new project, but I'm still getting the error.
The link provided in the first comment to the question by steve-green solves the issue.
... use the config file to specify the
DbConfigurationinstance to use. To do this, set the
codeConfigurationTypeattribute of the
entityFrameworksection. For example:
<entityFramework codeConfigurationType="MyNamespace.MyDbConfiguration, MyAssembly"> ...Your EF config... </entityFramework>