ASP.NET MVC Web App on 3-Tier for Beginners – Part 2

Introduction

This article is the continuation of Part 1. In the first article, we saw understanding of requirements and then breaking them into objects, then finding out the relationships among them and finally designing and implementing the database. Now, let us see how to create a solution, then add multiple projects to it and then add desired references to the respective projects.

2: Analysis and Design (Creating Solution and Projects)

Create a new project in Visual Studio as LinkHubUI, choose desired path and click OK.
Select Empty project, check the MVC check box and click on OK.
Now, we will add some list of tasks which will make us implement the project easily. We will add a text file, right click on project, add Add New Item and name it as ToDoList.txt.
This ToDoList contains the list of tasks that we need to perform.
This is a step-by-step process to implement the layered architecture in MVC. I’ve done a little hard work on it to give you these steps. So, I’m sure this is very much helpful for you when you are implementing a project for the first time.
Now our first task is creating a solution with all projects.
Right click on solution and add new project. Choose from C# -> Class Library and name it as BOL (Business Object Layer).
Remove Class1.cs file from BOL project.
Add one more Class Library project and name it as BLL (Business Logic Layer) and delete Class1.cs from BLL project.
Finally, add one more new Class Library project and name it as DAL (Data Access Layer) and delete Class1.cs file from DAL.

Our Project Architecture

Now, if we look at our architecture, you can see that UI is interacting with BLL and BOL.
So, I need to add BLL.dll and BOL.dll in UI.
BLL is interacting with BOL and DAL. Add BOL.dll and DAL.dll references to BLL.
DAL is interacting with BOL. Add BOL.dll reference to DAL.
If I try to add reference of BLL.dll for DAL, there will be an error (Circular Dependency).
So, we should add the references moving from left to right only. Save All and Rebuild Solution.
Now, we are set with all projects and DLLs. We are done with the first step in ToDoList. In our next article, we will see creating BOL with the help of Entity Framework.
Thanks for reading.

Comments