I have an ASP.NET application using an Entity Framework 6 model as the data access layer. It is in its own assembly.
In a separate assembly, I have a business logic layer which has many classes with names that overlap with the Entity model classes. The classes in this assembly are in a separate namespace from the DAL model.
So, for example:
DB Tables
- TableA
- TableB
- TableC
- etc..
Entity Framework DAL classes (Assembly: ProjNameDAL)
- OrgName.ProjName.DataAccess.TableA
- OrgName.ProjName.DataAccess.TableB
- OrgName.ProjName.DataAccess.TableC
- etc..
Business Logic Classes (Assembly: ProjNameBLL)
- OrgName.ProjName.TableA
- OrgName.ProjName.TableB
- OrgName.ProjName.TableC
- etc..
I didn't have any problems with this setup all the way through development and deployment. In fact, I've used this pattern in multiple projects. But, yesterday I made a schema change to the database, updated my DAL and BLL, and compiled my project. When I try to execute SOME (not all) BLL methods that use the DAL, I get the dreaded CLR/EDM ambiguous type mapping error:
The mapping of CLR type to EDM type is ambiguous because multiple CLR types match the EDM type 'TableD'. Previously found CLR type 'OrgName.ProjName.DataAccess.TableD', newly found CLR type 'OrgName.ProjName.TableD'.
I get this message for 3 of the overlapping types, none of which are even used in the method in question.
If I change the BLL class names, of course this works around the issue. But, I'd rather not have to prefix/suffix my naming conventions if possible.
I have read up on the limitations with using multiple EF models, but the conditions for that don't seem to directly apply here. Plus, I have had nearly identical configurations working well in the past. Can anyone explain this runtime error and how I might avoid it?