Alex Rivera | Logout

EF4 Poco Issue Mapping Types Same Name Same Assembly Different Namespaces

Asked 2010-07-28T14:56:29.773
23

I am experiencing an issue with EF4 and Proxy Pocos.

I have 2 classes with the same name in the same assembly but different namespaces:

QuoteModels.CashPayment
OrderModels.CashPayment

This compiles fine but at runtime EF throws the following exception:

Schema specified is not valid. Errors: \r\nThe mapping of CLR type to EDM type is ambiguous because multiple CLR types match the EDM type 'CashPayment'. Previously found CLR type 'QuoteModels.CashPayment', newly found CLR type 'OrderModels.CashPayment'

Is there a workaround to have classes with the same name in the same assembly with different namespaces to work with Ef4?

Do I have to give them different names or move them into another assembly?

Edit
Report

1 Answer

0

What I did was to delete one of the repeated entities and for the other entity create a partial class that has the properties of the deleted entity

Example:

namespace Namespace1
{
 class Talk
 {
  public int TalkId {get; set;}
 }
}
namespace Namespace2
{
 class Talk
 {
  public int TalkId {get; set;}
  public string SomeExtraInfo {get; set;}
 }
}

Result:

namespace Namespace1
{
 class Talk
 {
  public int TalkId {get; set;}
 }
}
namespace Namespace1
{
 partial class Talk
 {
  public string SomeExtraInfo {get; set;}
 }
}

Hope it helps someone

answered 2013-01-15T19:36:49.360

Your Answer