Monday, May 28, 2018

Part 57- Repository Pattern- 4 - Adding Data Access Layer OR Repository Layer

In this tutorial, You will learn about how to add Data Access/Repository Layer under repository pattern implementation in Asp.net MVC . In Repository pattern I will create different layers but it depends on you whether you need this or not. You can directly create Data Access Layer and create the generic repository methods into this. I will explain generic repository in my upcoming videos. Lets look at below layers 

1. Web Layer is your MVC web Project
2.  Business Layer consist the CRUD operation, gets data from Data Access Layer, Manipulate them and finally returns data to the Controller ( Web Layer)
3. Domain Layer consist the Domain Models or Classes that hold the data coming from Data Access Layer. Both Web and Business Layer can use domain models to exchange data.
4. Data Access Layer consist the generic repository methods (generic CRUD operation), Unit of Work( Database Context) and NON Generic repository( User defined repository).




#How to create Data Access Layer? 

 Please follow below Steps 

Step 1 : Right Click on your solution and click on Add, then click on New Project.





Step 2 : After opening the popup, select class Library option and give a meaningful name






# How to add Entities into Data Access Layer?
       
Please follow below steps 

                                       A. (Right click on project then add new item)

B . (Select ADO.NET Entity Data Model and give any name)

. (Choose EF Designer then Next)

. (Click on New Connection and Add Server and database. Then Click next)

. (Select Server and Database then click on test connection and ok)

. (Check the dbo checkbox and give a meaningful name and finish)

. (You are done !!!)




Note: In video I explained how to access above entity into Business Layer. But that was just to extra knowledge. I am going to access this entity framework in generic and custom repository methods in next tutorial. 

What Next => In next tutorial we will learn how to  create Generic Repository Methods with UnitOfWork and how to use above Entities. 

Please Like, Share and subscribe our Channel. Have a great day.


All Code Factory


No comments: