Tuesday, May 20, 2014

Tuesday, May 6, 2014

The type 'xxxxx' and the type 'yyyyyy' both have the same simple name of and so cannot be used in the same model. All types in a given model must have unique simple names. Use 'NotMappedAttribute' or call Ignore in the Code First fluent API to explicitly exclude a property or type from the model.

Recently i have faced this issue with Entity Framework . The issue  occurs when dbset property  refers the Mapping class instead of Entity . I fixed the issue by changes the  dbset property entity type (Instead of mapping class referred Entity class).

Here are the rules

  • The dbset property should  have the Entity
  • In model creating we should specify the mapping class

Working Example

   As you see below screen shot  the first one(dbset property for Contractor Visits) referred the POCO entity

and  in the configuration referred the Mapping class of ContractorVisist.

image

 

Now it worked fine . Let me know if you still facing any issues ..