views:

188

answers:

2

I have an existing model for my project. I would like to switch to Entity Framework but I don't want to replace my model with the model generated from EF.

Additionally, my model is very different from my database schema so any chances to use the model generated from EF and do all the required refactoring seems too hard.

Does exist any way to have an existing domain, an existing database and use EF only to add methods to my domain to include the O/RM layer?

+1  A: 

In .NET 3.5SP1, then the answer is a big fat "no" I'm afraid. In .NET 4.0 the story looks more promising, with POCO support being introduced (which should hopefully let you use your own objects, although I haven't tried it on the public beta yet).

Note that you can do POCO (with your own objects) with LINQ-to-SQL, by using an external mapping file (and supplying a DataContext object) - but the tools don't exactly help you to do this (it wants to use code generation by default).

For now, maybe NHibernate (and similar) is your best choice.

Marc Gravell
+1  A: 

You can download the beta release of Entity Framework if you are an MSDN subscriber. It has support for POCO object which is what you are referring to and for which EF 1.0 came under heavy criticism for.

The ADO.NET Design Team has just recently posted @ POCO in the Entity Framework: Part 1 - The Experience which will help you get right on track.

From my experience with using EFPocoAdapter (precursor to EF 4.0) I am happy to suggest EF 4.0.

You also get support for some cool n-tier scenarios which means you can pass your objects to another layer, which can modify and return them and you can still persist them to the database. And the other layers don't have to know anything about the entity framework so you get clean separation of concerns.

aleemb