Search code examples
c#asp.netlinqentity-framework3-tier

Entity Framework best practice with asp.net webforms application


I am building as asp.net application on .net framework 4.0 and I will be using Linq to entities (Entity Framework) as my DataModel (DAL), my design pattern will be the 3-tier layers where the Entity Framework will be the DAL layer.

My question is should I have a BLL layer for my tables so that I deal with it from the presentation layer (my pages) where I call my select, insert, update and delete functions from or it is better to call the Entity Framework directly in my presentation layer?


Solution

  • It depends on the application; layers are not defined because they are good, layers are defined because they are needed.

    If your application is a big one and business rules are subject to change often, then go build a BLL layer. Otherwise, IMHO, it is just overengineering. The scale of your application and the rate of change should be your main concern when deciding.

    Note that, if you call EF directly, your business rules will be inside your presentation layer. If they are subject to change, then refactoring the presentation layer will be a mess as well reusability will be lower.

    But again it depends the scale of your application, your project schedule, the rate of change of business rules and other factors.