Click here to Skip to main content
15,030,781 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Is repository pattern is useful with entity framework or not

What I have tried:

searching on google and asking for friend but i am not get any idea
Posted
Updated 2-Nov-16 3:56am
Comments
[no name] 2-Nov-16 7:01am
   
If it helps you solve a problem, then sure it's useful.

Many argue that EF already implements Repository pattern, so there is no point in abstracting the abstraction....
But, I'm glad I created my own abstraction over it. So one could easily change from EF to another OR-mapper - but I think this is a quite unlikely scenario... But what happens all the time is that there is a new version of EF - and not having to change the dependency (to EF) in a lot of projects is a big benefit. Also writing unit-tests for the data-access code is easier (e.g. by injecting an In-Memory-Repository implementation, which doesn't need a database or -connection for Tests.

So in general (mostly if you use generated models) there is no Point in creating your own absraction over EF.
In very big solutions with many projects, dependency mmnagement is crucial (think about creating Setups and so on). So additional abstraction can have it's benefits. (many other solution possible)

I'd say: If you see a real reason to create your own abstratction, do it. If you don't have one now - follow the YAGNI prinicple!!!

Kind regards Johannes
   
The Repository pattern hides the details of how the data is stored/retrieved. If that makes your code easier to read and/or understand then it is "useful". Try reading the examples of Repository pattern here [^] and here[^]
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900