Where to place Business Logic classes in Entity Framework - ASP.NET MVC 4 solution?

I have a solution with one project - the Entity Framework and my ASP MVC project, I am looking for some tips or opinions on the idea of ​​creating at the top of my POCO and DBContext objects - a business logic level with static classes that have all methods (for example, a class ContactBLL with GetContactByID, GetAllContacts, GetContactsByType) to allow access to model data and which can be accessed in controller actions. Thus, I do not need to enter the implementation code of these methods into the Actions Controller methods, and it can be reused using these methods in other Action Controllers. I will be grateful for your opinion, because it can help me answer the question that I asked myself for about a week, based on the answer to this question (about where to determine the DBC context and how to use it).

+3
source share
3 answers

You can create different projects in accordance with the main functions.

  • The data access level (context and DB repository, etc.) you can create Project.DataAccess, it will only have a class and db repository.

  • The business logic level (Project.Business) will have business logic and make a call at the data access level.

  • UI Layer (Project.WebUi) - mvc project. etc.

for details you can see this http://prodinner.codeplex.com/ code

+4
source
  • Create a separate class library for your POCO,

  • then create another class library for your repository, this should include only the interfaces needed for your repository

  • lib, Project.EF, Project.NH, , , . , , ORM lib, , ( 2).

  • - ( lib)

  • - lib. "" MVC ViewModels.

, , , , , :). , .

+1

, ASP.NET MVC - Entity Framework. 1) MVC, 2) Core/Business Logic Layer (BLL), 3) /DBContext (DAL) 4) Common/Utility.

  • MVC : Model, View Controller. Model MVC BLL, ViewModel (POCO). , MVC- / BLL UI .

  • - (BLL) -. MVC DAL . , BLL - , ViewModel, , / . Viewmodel (POCO), , DAL, . , ViewModel, ,

  • DAL - DBContext .

  • , Logging, 1) 2) 3)

Please read more at https://www.codeproject.com/Articles/70061/Architecture-Guide-ASP-NET-MVC-Framework-N-tier-En https://chsakell.com/2015/02/15/ asp-net-mvc-solution-architecture-best-practices /

0
source

All Articles