EF Codefirst Approach, Context Factory, Generic Repository Pattern, Unit of Work Pattern

Firstly i want to take a look at Generic Repository and Unit Of  Work Design Pattern.

Repository Concept:

  • Separate business code from data access
  • Encapsulate data access
  • Anytime you need data persistence

RepositoryConcept

Unit Of Work Concept:

  • You can prefer for effecient data access
  • Manage concurrency problems and transactions

UnitOfWorkConcept

Now, Let’s write code for Context Factory Classes

Write code for Repository Design Pattern

Write code for Unit of Work

Now, Class diagrams for existing codes

UnitOfWork

The most important point In the Unit of Work Design is consisting of Context instance(via Context Factory) and Repository Classes.

UnitofWork2

Generally we saw using repository , context factory and unit of work patterns for codefirst approach, see you

Leave a Reply

Your email address will not be published. Required fields are marked *