Mapping from Entity Framework to classes of custom domain classes?

I wonder how I can get automatic matching between entities generated by an entity framework (.NET Framework 3.5 SP1) and classes of custom domain classes? I know that I can create some data converters that will move objects back and forth between two worlds, but how can I do this automatically?

I started developing domain model classes, decorating them with validation attributes from a validation application block that cannot be used inside entity classes that are automatically generated (and updated) by the entity infrastructure. Therefore, it is necessary to automatically - or at least with a minimum written code - a comparison between the EF and the domain model. Any idea?

+4
source share
3 answers

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

+2
source

Since EF 4 is now possible, you should take a look at Julia Lerman's EF blog. She recently published a series of publications about the POCO script and repositories with EF4:

http://thedatafarm.com/blog/

With EF 3.5, this is tricky, but you can still use Automapper if your class has the same set of attributes ...

http://automapper.codeplex.com/

+1
source

You can use the Application Validation block with generated objects, but you cannot use an attribute based approach. The Application Validation block also allows you to use configuration files to determine the validity for entities (and contains a great Visual Studio plugin for editing this configuration file). I wrote about using VAB with Entityity Framework here . This article may come in handy for you.

Good luck.

+1
source

All Articles