Entity Framework – Who Needs a Data Access Layer (DAL)

entity-framework

On EF4 actions on entities are actually done via the Business Element layer (BE).

Why do I need the Data Access (DAL) on another layer?

Best Answer

It's usefull to wrap entity functions with a service/ DAL layer.
This helps to define a clear distinction between business logic(in a backing bean), and data operations(in a DAL).
So the bean purely deals with business logic, and the data operations as simply called. This means if you later change the data operations, you don't affect the business logic layer(as much). Much like the division that should be between the view and business layer. The view layer should not be doing any business logic(with the exception of validation, and you could argue that could still be a call to the business logic).

You'll also find you will probably use the same data operation repeately throughout your application, so if you have it wrapped in a service class, it's easy to reuse.

My own rule of thumb is, if you have a entity manager in a backing bean, then your doing it wrong.

Related Topic