Reputation: 183
I'm developping a line of business application using WPF as a presentation layer (of course with MVVM).
I'm using ADO.Net Entity Framework to map the DataBase.
I don't want to use entities directly in code (in the business layer). I want to separate my project into 3 layers:
Presentation layer
Business Layer
Data Access Layer
According to this post I want to implement a full encapsulation of the Entity Framework to provide a separation of concerns and to not be dependant on EF as ORM in the future.
Can you help me by giving me some exemples to encapsulate the EF and how to implement this in code.
Upvotes: 3
Views: 2748
Reputation: 93
There is one way of doing it, using POCO. Entity Framework 4.0 comes with the support of POCO (Plain CLR Objects). But POCO has its own complexities, when u have to deal with Relationship and associations. You can refer to the blog by Julie Lerman (a nice article)
Upvotes: 0
Reputation: 9599
I would take a look at this post wich implements UnitOfWork and Repository patterns to implement what, I understand, you want to achieve.
Upvotes: 0
Reputation: 18181
Regarding this
I want to implement a Full encapsulation of the Entity Framework. to provide a separation of concerns and to not be dependant on EF in the future as ORM
Normally, you will create yourself a lot of problems if you go that route. If you choose EF, you really should make full use of the features, not hiding that behind another abstraction.
EF itself is already an abstraction layer over DB, there is no need to create another abstraction on top of that.
Upvotes: 10