First, I use a database, and I have a switch that looks something like this:
switch (site) { case Site.One: using (OneContext one = new OneContext()) return one.OrganizationObjects.SingleOrDefault(x => x.u_Name == orgName)?.g_org_id; case Site.Two: using (TwoContext two = new TwoContext()) return two.OrganizationObjects.SingleOrDefault(x => x.u_Name == orgName)?.g_org_id; default: throw new NotImplementedException(); }
Both databases are pretty similar and have almost all of the same models.
If I delete the Two EDMX file and comment out this condition, OneContext works fine.
If I add the TwoContext EDMX file to the project and run the code again, the "OneContext" code will fail when it tries to query OrganizationObjects.
I made sure that each context uses the correct connection string, but this error still occurs:

c # entity-framework ef-database-first
ernest
source share