Generic Repository and Unit of Work Pattern With Entity Framework 6
The Repository Pattern is one of the most popular patterns in an N Layered application. An example of N layer system may consists of Presentation Layer, Service layer, Business Layer and Data Access Layer. The Repository is an abstraction on top of the Data Access layer. Using Repository/Unit of work pattern, we can hide EF implementation from business layer, and thus it makes our code more test friendly.
If you plan to use Entity Framework Core, please checkout Repository and unit of work patterns for EF Core and In-Memory Database Provider.
-
Open the project/solution in Visual Studio, and open the console using the **Tools > NuGet Package Manager > Package Manager Console command
-
Enable DB migration
$ Add-Migration init
- Create dabase
$ Update-Database –Verbose