0

I have two Databases but both databases have same schema.I have added their edmx files in different folders to separate namespaces but still I am getting this exception:

The mapping of CLR type to EDM type is ambiguous because multiple CLR types match the EDM type 'bettingoffer'. Previously found CLR type 'SpocosyPanel.Data.Tennis.bettingoffer', newly found CLR type 'SpocosyPanel.Data.Soccer.bettingoffer'.

My question is how can I use two edmx files which are apparently same but from different data sources

Ans Bilal
  • 987
  • 1
  • 10
  • 28
  • 1
    This is possible duplicate but it is same error but other question does not have answer yet. https://stackoverflow.com/questions/14927391/the-mapping-of-clr-type-to-edm-type-is-ambiguous-with-ef-6-5 – dotnetstep Aug 19 '18 at 08:44

1 Answers1

3

Yes, it is a known bug in Entity Framework 6 and below. You could not use the same databases even though they are on different namespaces. This is happening in code first design as well and a post was opened on GitHub regarding the issue as well.

One of the developers even answered it stating:

This is already supported in the EF7 code base. We didn't really do anything to explicitly support it, it was just a side effect of the lighterweight purpose built metadata system in EF7 smile.

Meaning, that if you use Entity Framework 6 or below there is not much for you to do except not using the same Database twice in your code.

Barr J
  • 10,636
  • 1
  • 28
  • 46
  • 1
    So whats the solution? – Ans Bilal Aug 19 '18 at 08:50
  • There is non for Entity Framework 6 and below, this bug will forever stand as the fix only applied for Entity Framework 7. You will have to use different databases. – Barr J Aug 19 '18 at 09:41
  • The most effective workaround is to rename either the entity (EDM) class or the CLR class, if you can. Sometimes having a different public property between the classes will also work; even changing the name sometimes works. – Suncat2000 May 14 '20 at 12:41