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?
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
DataContextobject) – 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.