Timeline for Why shouldn't I use the repository pattern with Entity Framework?
Current License: CC BY-SA 3.0
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Mar 15, 2017 at 17:51 | comment | added | Joel McBeth | @JamesCulshaw I saw it, but I was responding to your answer, and your comment also doesn't address my main point, that you didn't enumerate any of the other advantages. | |
| Mar 15, 2017 at 16:12 | comment | added | James Culshaw | @jcmcbeth if you look at my comment directly above your you will see that I have changed my original opinion with regards repository pattern and EF. | |
| Mar 14, 2017 at 23:18 | comment | added | Joel McBeth | I don't think this is a good answer because your supporting statement is just that there are numerous advantages while only listing one.The one you do list isn't a good reason because you can use an in-memory database for entity to do unit testing. | |
| Mar 26, 2016 at 19:33 | comment | added | James Culshaw | I'm actually beginning to question my earlier opinions on this. EF is a combined Unit-of-Work and Repository pattern. As Chris Pratt mentioned above with EF6 you can easily mock the Context and DbSet objects. I still believe that the data access should be wrapped in classes to shield the business logic classes from the actual data access mechanism, but to go the whole hog and wrap EF with another repository and Unit of Work abstraction seems to be overkill. | |
| Mar 24, 2016 at 4:56 | comment | added | Brandon | One more thing I just wanted to add. Yes CQRS is a vastly superior methodology in MOST cases. For some clients I have worked at when the database guys dont work well with developers (which happens more often than one would think especially at banks), EF over SQL is the best option. In that specific scenario, when you have absolutely no control over your database, repository pattern makes sense. Because closely resembles the data structure and is easy to translate whats going on to the database and vise versa. Its really a political and logistical decision in my opinion. To appease the DB gods. | |
| Mar 24, 2016 at 4:39 | comment | added | Brandon | I agree with this answer. My repositories are basically just extension methods, which do nothing but build expression trees. Over a VERY simple abstraction that simply provides generic functionality directly over the top of dbcontext. The only real purpose of the abstraction is to make IoC a little easier. I think people try to do things in their repositories that they shouldn't do. They make on repo per entity, or put business logic in there that should be in the services layer. You only ever actually need one simple generic repo. Its not necessary, just provides a consistent interface. | |
| Feb 3, 2015 at 14:47 | review | Suggested edits | |||
| Feb 3, 2015 at 15:25 | |||||
| Jun 20, 2013 at 15:41 | history | answered | James Culshaw | CC BY-SA 3.0 |