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.Metadata) Entity mapping.
EntityFramework uses the class name & properties only, the namespaces are ignored in EDMX. We are unable to specify the exact class.
Here we have two different .edmx file in different folder with same table Customer.

EF_2


  

  
  

This is ok while we compile our app, but this will cause an error while we are going any operation with this model.

Let’s create a Controller using EFEF_3

Click Next

EF_4

This will cause this type of error.

EF_1

Solution:

Simply create different .edmx file in same folder. Thus we can automatically manage our conflicted class in .tt file.

Let’s just remove the folder and create both .edmx file again with same table in both .edmx file.

EF_5

Both .edmx file have same table Customer but they are referenced from a single class. As we know the namespaces are ignored in EDMX, this will act like a single .edmx file.

Both Models:

Customer ModelEF_7

Employee ModelEF_8

This is how we can separate our .edmx file using same table in multiple edmx.

Out Put:EF_6

Hope this will help 🙂

Author:

Since March 2011, have 8+ years of professional experience on software development, currently working as Senior Software Engineer at s3 Innovate Pte Ltd.

Leave a Reply