开发者

POCO and non-POCO in the same class library project

In one of my projects I have some models that I don't want to use with POCO i.e. use the EF generated classes and some others where I want to use POCOs. When I mix those, the POCO mapping doesn't work and I get an except开发者_JAVA百科ion

System.InvalidOperationException was unhandled by user code Message=Mapping and metadata information could not be found for EntityType 'xxxxx.xxxxx.xxxxx.xxxxx'. Source=System.Data.Entity

This message usually is something incorrect in connection string. However, after through inspection I could confirm that there is nothing wrong with that or the generated POCO classes. I also found that

Mapping POCO entities is not supported if any mapping attributes are applied to custom data classes, including EdmSchemaAttribute at the assembly level.

in MSDN article Working with POCO Entities. While the simplest solution is to split the project into two parts and keep POCO and non-POCO separately, I wanted to see if there is another way around.


Looks like there isn't a way to this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜