I'm using database first and I have a switch
statement 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 the all of the same models.
If I delete the "Two" EDMX file and comment out the condition, then OneContext works perfectly.
If I add the TwoContext EDMX file to the project and run the code again, the "OneContext" code fails when it tries to query OrganizationObjects.
I made sure each context was using the correct connection string, but this error still occurs:
The mapping of CLR type to EDM type is ambiguous because multiple CLR types match the EDM type
– Oodles