none
EF5 Mapping of CLR type to EDM type is ambiguous error RRS feed

  • Question

  • The issue 1: You create 2 models for 2 databases which have the same table name, e.g. Countries.

    The issue 2: You create a model for a database which has a table with name Countries and there is a BLL class MyNamespace.Country.

    In both cases it does NOT matter whether or not the models/BLL have the same namespace or reside in the same assembly. In all cases it results in the error:

    --------------------------------------

    Schema specified is not valid. Errors:

    The mapping of CLR type to EDM type is ambiguous because multiple CLR types match the EDM type 'Country'. Previously found CLR type 'MyProject.MyModel1.Country', newly found CLR type 'MyProject.MyModel2.Country.

    OR

    The mapping of CLR type to EDM type is ambiguous because multiple CLR types match the EDM type 'Country'. Previously found CLR type 'MyProject.MyModel1.Country', newly found CLR type 'MyProject.MyBLL.Country.

    -------------------------------------

    I found that many people complained about that in EF4 but it seems not to be fixed in EF5.

    Is there workaround rather than manually rename entities in the model?

    Is is possible to change the T4 templates to generate entity names like <DatabaseName><TableName> instead of <TableName>?

    Tuesday, October 30, 2012 7:41 PM

All replies

  • Hi miksh,

    Welcome to MSDN Forum.

    "This is a limitation of EF that we plan to fix but it is complicated and not something we are planning to address in EF6. Marking to be fixed in a future release."

    This issue has tracked here. Now, you can rename the entities as the workaround. : )

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, November 1, 2012 2:13 AM
    Moderator
  • Hi Allen, thanks for reply.

    I understand that it is complicated. Meanwhile, it would be great if MS EF team will publish the modified T4 templates to generate the model to make entity names like "<DatabaseName><SchemaName><TableName>" and let developers choose the proper naming convention.

    E.g. for AdvantureWorks the generated entites would be:

    • AdventureWorksDboErrorLog
    • AdventureWorksHumanResourcesDepartment
    • ...
    • AdventureWorksPersonAddress
    • etc

    Friday, November 2, 2012 6:00 PM