Could it be bad practice to make use of the code-gen'ed objects from Entity Framework as business objects? Or is it more beneficial to create another wrapper around Entity Framework objects which i would then pass between layers?

For instance, write my very own POCO Person who accepts among my code-gen'ed Entity Framework object EFPerson to initialize the POCO Person object?

While many people often wrap the Entity Framework classes to their business objects, I'd usually suggest to avoid that.

I realize this enhances the separation of economic logic and data access, however i believe that normally, this is not well worth the overhead of copying all entity types.

What's the reason for an OR mapper? It's to persist business objects with no need of an intricate data access layer mapping the objects towards the database manually. Should you wrap the Entity Framework classes, you will simply use 1 / 2 of the acquired convenience.

And lastly the coupling between data access and business logic isn't that tight with partial classes. Not sometime ago I transformed a task including about 30 organizations from Entity Framework to LINQ to SQL in just a couple of hrs without major problems.

I do not understand why it might be bad practice. It may be awkward based on how you want to make use of your EF objects.

I've partial classes to implement BIZ logic within the EF objects, utilizing an Interface to supply an amount of abstraction.


public partial class Client : IClient
   void DoSomething();

// then an EF generated object ...
public partial class Client
 // ...

My only problem I've had is serializing the objects. During my situation, serializing into JSON using WCF. It is not possible without creating medium difficulty DTO either like a discrete class/object or being an anonymous type.

If you are thinking about serialisation, take a look at another question of mine here: