0

I was trying to figure out Unit of work pattern for EF.In couple places I have read that DBcontext in EF6 comes with UOW and Repository by default.

I am little confused now . Do I Need to explicitly write UOW for dbcontext of EF6 or i can just use it as DbContext.table.Commit() it will do the same.

  • If you plan to unit test `UOW` and `Repository` implementation will have greater testability – Eldho Dec 29 '15 at 06:31

1 Answers1

0

Yes Entity framework already have UOW and Repository Pattern. However when we explicitly write UOW and Repository over entity framework it will create one more layer over default Entity framework model, we usually do this because in future we might change our ORM (Entity framework) to some other and that may not have UOW and Repository pattern.

Majed
  • 53
  • 8
  • +1 , thanks for the comment Majed. It all makes sense now. but to keep UOW and Repository pattern independent of ORM where do you implement it in your Projects in Service layer or you will have separate layer between Service and Data where this is implemented. – SIDDU HUSSAIN Dec 29 '15 at 18:08
  • This is a fake abstraction. You'll soon see that your allegedly ORM-independent UoW and repo will exhibit all kinds of features (parameters, methods) that reveal that EF is under the hood. Just one example: http://stackoverflow.com/a/15844995/861716 – Gert Arnold Jan 01 '16 at 11:10