Luis Valencia
Luis Valencia

Reputation: 33978

Entity framework and n-layered application

so, I have this:

  1. Web App
  2. Business Logic
  3. Data Access Logic

I created in the data access logic, the entities, the context, the initializer.

SO usually the higher layers, call the lower layer functionality, right?

If I want to save a customer, I want to create a Customer entity from the web app. What I dont like is having a direct reference from the web app layer to the data access logic layer (class library)

any idea?

Upvotes: 0

Views: 949

Answers (2)

Shyju
Shyju

Reputation: 218702

This is how i did it on a previous project

4 Projects under my Solution

1) UI ( my ASP.NET MVC Application)

2) Business Entities ( My POCOS's for Entities like Customer, Order etc..)

3) Business Logic ( My Inermediate Service Layer which stays in between UI and DataAccess layer. I would do my business specific validations here.

4) The Data Access Layer. Talks to my database. Can be EF / pure ADO.NET Stored Proc etc..

  • DataAccessLayer Project has references of Business Entities Project
  • Business Logic Project has refereces of Business Entities Project
  • UI Project has refereces of Business Entities Project and BusinessLogic.

From UI, I call methods of Middle Layer (Business Logic) and from there after doing custom validations / business rules, i would call Data Access Layer methods.

Upvotes: 0

MDL
MDL

Reputation: 271

I know this probably isn't very constructive but if I was you I would just add the reference. There no point making things harder on your self to find a more complicated way to do something which should be easy. plus if you skip it now and come across a better solution later you can just modify your code.

Upvotes: 1

Related Questions