Full encapsulation of the Entity Framework

I am developing a line of business applications using WPF as my presentation layer (with MVVM of course). I am using Ado.Net Entity Framework to display a database. I don't want to use objects directly in code (in the business layer). I want to separate my layers: -presentation layer -business layer -Data Access Layer

According to this post http://www.wadewegner.com/2009/06/architecting-your-data-access-layer-with-the-entity-framework/ I want to implement full Entity Framework encapsulation. ensure separation of concerns and not depend on EF in the future as an ORM

Can you help me by giving me some examples for encapsulating EF and how to implement it in code. THH


source to share

3 answers

Regarding this

I want to implement full Entity Framework encapsulation. c provide separation of concerns and do not depend on EF in the future as ORM

As a rule, you will create a lot of problems for yourself if you go this route. If you choose EF, you really should be making full use of the functions and not hiding it behind another abstraction.

EF itself is already an abstraction layer over the database, there is no need to create another abstraction on top of that.



I would take a look at this post which implements UnitOfWork and Repository to implement what I understand you want to achieve.




There is one way to do this using POCO. Entity Framework 4.0 comes with POCO (Plain CLR Objects) support. But POCO has its own challenges when you have to deal with Relationships and Associations. You can refer to Julie Lerman's blog (good article)




All Articles