Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shall, I implement Repository, Unit of Work for EF6?

Since MSDN says about DbContext:

A DbContext instance represents a combination of the Unit Of Work and Repository patterns such that it can be used to query from a database and group together changes that will then be written back to the store as a unit. DbContext is conceptually similar to ObjectContext.

Is it not redundant to implement these two (Unit of Work & Repository) when using EF5+?

Can somebody shed more light on this subject?

I intend to build an MVC based application using SQL server and after reading a lot about data access techniques with unit testability, I am kind of lost with the above info!

like image 451
Numan Avatar asked Nov 01 '22 05:11

Numan


1 Answers

That depends on the complexity of your project and its requirements. For instance, these two questions might help your decision making:

  1. Will you use any other data sources besides EF that must work along it?
  2. How likely it is that you swap EF for a different ORM or data source in the future?

If you can't foresee changes or you don't need to work with more than just EF then it's probably not worth the trouble.

like image 63
jnovo Avatar answered Nov 15 '22 05:11

jnovo