Friday, February 8, 2019

Why DBSet and DBContext are not enough for Repository and UOW

Why DBSet and DBContext are not enough for Repository and UOW

DBSet and DBContext are the half of the story. They are completed by Entity Specific Repositories and Application or sub application specific UOW.

Only by having Entity specify Repo classes we can reap the benefits of Repository Pattern.

I am not sure application specific UOW is good or not. see mosh lectures and mathew rinzee Codebase.


EF provide UOW (DbConext) and Repositories (DbSet) but using them directly in
Controllers or Services is not required. Doing so reuslts in all disadvanges of poorly
architectured code.
We need to have Wrappers around EF UOW (DbConext) and Repositories (DbSet)
We put interfaces on top of these wrappers IUnitOfWork and IRepositories
Services and Controllers use these Interfaces to do persistence
All these interfaces are defined inside the Service or Controller layer
DI/IOC is used to intect depedencies to controllers or Services
Only then we get benifits of Good Arch

No comments:

Post a Comment