The mapping of CLR type to EDM type is ambiguous because multiple CLR types match the EDM type
See original GitHub issueSchema specified is not valid. Errors:
The mapping of CLR type to EDM type is ambiguous because multiple CLR types match the EDM type 'Crop'. Previously found CLR type 'AFI.Core.DataModels.gen2.Crop', newly found CLR type 'AFI.Core.DataModels.gen3.Crop'.
I get this exception at runtime when querying entities from a database via LINQ. In my project I use Database First and I have two classes with the same name but different namespaces. Each class belongs to a separate model and each model has its own connection string and thus own database.
This bug is at least two years old. The orginal bug has been posted by mousedoc here: http://entityframework.codeplex.com/workitem/483
Are there any plans on fixing this bug in the nearest future?
Issue Analytics
- State:
- Created 9 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
The mapping of CLR type to EDM type is ambiguous with ...
The mapping of CLR type to EDM type is ambiguous because multiple CLR types match the EDM type 'City_DAL'. Previously found CLR type...
Read more >The mapping of CLR type to EDM type is ambiguous
The mapping of CLR type to EDM type is ambiguous because multiple CLR types match the EDM type 'CmnAddressCity'. Previously found CLR type...
Read more >The most ridiculous thing ever in Entity Framework : r/dotnet
Schema specified is not valid. Errors: The mapping of CLR type to EDM type is ambiguous because multiple CLR types match the EDM...
Read more >The mapping of CLR type to EDM is ambiguous
This happens because of EntityFramework While CSDL (Conceptual schema definition language , instance of the System.Data.
Read more >The mapping of CLR type to EDM type is ambiguous
The mapping of CLR type to EDM type is ambiguous because multiple CLR types match the EDM type 'CmnAddressCity'. Previously found CLR type...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@davimack This repo is for EF Core, so the issue was closed because there is nothing actionable that applies to EF Core. The bug remains open in the EF6 repo at http://entityframework.codeplex.com/workitem/483.
BTW, in one of the minor releases of EF6.x we added annotations that can be put in entity types in the EDMX to identify the CLR type they will be mapped to at runtime deterministically, which avoids scanning assemblies for all possible candidate CLR types and avoids the exception.
The EDMX needs to be edited manually to add the annotations since the tools won’t add them. For a simple model with a Person entity, the ConceptualModels section of the EDMX would look like this:
Notice in particular the
customannotation:ClrType
on the Person entity type and thecustomannotation:UseClrTypes
on the entity container.How would you go about doing this with ComplexTypes?