How do you implement a business logic layer when using entity framework as data access layer?

user938866 picture user938866 · Aug 22, 2012 · Viewed 10.8k times · Source

Say i have 3 layers

layer 1: WPF Project (contains: xaml, viewmodels, mvvm framework)

layer 2: business logic layer (contains: plain c# classes)

layer 3: entity framework (contains: repository/data access classes)

when you dont want to expose your DAL(layer 3) to View(layer 1) how do you implement the business logic layer well? im having a hard time putting values back and forth the BLL objects and DAL entities.

can you please help?

Answer

Scott Scowden picture Scott Scowden · Aug 22, 2012

Entity Framework doesn't work really well in a "disconnected" model. Unless something has changed, I've never been able to get it to work great easily.

You could use AutoMapper in Layer 2 to create ViewModels to present to Layer 1, but then you'd still have to send the changes back to Layer 3, which could be a pain.