views:

338

answers:

1

Hi, I had a little discussion with a friend of mine about the use of Entity framework. I had a project where I made a 3 tier solution with the entity framework as my datalayer, and used Data Transfer Objects to move from the business tier to user interface. I really liked the loose coupling it gives, since I can change the entity framework with e.g. hibernate later on. My friend on the other hand, was arguing that the purpose of the Entity framework was to model it so it could be used on the user interface. How do you couple the entity framework to your solution?

+1  A: 

I see the idea that my friend is proposing with the interchangable layers being Hibernate and EF, but I think its a little drastic as these two frameworks already contain DL->BL capabilities. I think the reason for using frameworks like EF and Hibernate are these, in prioritized order:

1. Direct usage of entities in business logic
2. Database type independence
3. Automatic caching
4. SQL Abstraction

Expecting that a framework like this should ALSO be loosely coupled to the tiers would just require too much query parsing, object wrapping and unwrapping and various noise to make up for the interchangability that might never become a reality. As i see it, his proposal would result in the equivalent of:
DL -> DL -> BL -> UL
Anyone agree on this?

I think you missunderstood me. When using the DTO, I on the businesslayer use the EF and when the calculations are done, I then make my transformation to EF-object -> Data Transfer Object and pass it to the user interface.
Dofs
After getting the site up, I found out that boxing and unboxing was way too slow...
Dofs