Last post Jan 12, 2017 06:09 AM by Cathy Zou
Jan 10, 2017 11:24 AM|bzinchenko|LINK
I have ASP.NET application, which uses several assemblies. Every assembly has own DbContext:
Assembly1.dll - DbContext1 - Configuration1
Assembly2.dll - DbContext2 - Configuration2
Assembly3.dll - DbContext3 - Configuration3
Main ASP.NET application references all these assemblies and tries to connect these contexts to 3 different databases with separate connection strings different per each context.
Configuration for each context is defined in this way (with type name suffixes 1, 2, 3 respectively):
public class Configuration1 : DbConfiguration
() => new System.Data.Entity.SqlServer.SqlAzureExecutionStrategy());
System.Data.Entity.Infrastructure.LocalDbConnectionFactory cf =
public class DbContext1 : DbContext
public DbContext1(string connStr) : base(connStr)
To my surprise, it does not work. First assembly connection works fine. Then second connection throws this exception:
An instance of 'Configuration1' was set but this type was not discovered in the same assembly as the 'DbContext2' context
Where Configuration1 is configuration defined in the first assembly. Of course, it is not defined in the second assembly. Why this cross reference comes?
This question with very detailed description was already asked here:
But it still remains not answered for 3 years. I wonder, if others have ever countered so common situation and how it can be resolved.
Jan 12, 2017 06:09 AM|Cathy Zou|LINK
For you problem, please check the following similar threads: