开发者

Mapping from Entity Framework to custom domain model classes?

I wonder how could I obtain an automatic mapping between entities generated by entity framework (.NET Framework 3.5 SP1) and custom domain model classes? I know I can create some data converters that translates the objects back and forth between the two worlds, but how could I accomplish this in an automatic way?

I started to develop my domain model classes, decorating them with validation attributes from Validation application block, which cannot be used inside the entity classes automatically generated (and refreshed) by the entity framework. Hence the need for automatically - or at least with minimal written code - mapping between EF and domain model开发者_Python百科.. any idea?


In EF 1.0, Automapper is a good choice for this: http://www.codeplex.com/AutoMapper


With EF 4 this is now possible, You should have a look at Julie Lermann blog about EF . She recently made a whole series of post about POCO scenario and repositories with EF4 :

http://thedatafarm.com/blog/

With EF 3.5 this is hard, but you could still use Automapper if your class have the same set of attributes...

http://automapper.codeplex.com/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜