Alternative to Entity Framework and the Repository pattern

About a year ago I wrote a post suggesting how one could approach the Repository and Unit of Work patterns when using Entity Framework, at the time I was somewhat new to Entity Framework and it was a shiny new toy that could do everything. Since then I've been involved in quite a few projects and though it is quite a nice framework, I've concluded that it's not the one tool to rule them all. I also realised that the Repository pattern isn't always the best approach to take.


Entity Framework executing stored procedures

Let's start with the code...


Entity Framework, Unit Testing and the Repository Pattern

I gave myself a problem. I started reading about test-driven development (TDD), and it had me intrigued. The way I generally developed websites was having the presentation layer of my applications (mainly MVC websites) somewhat tightly coupled with the data source. Controllers would be access the database via L2S or EF and pass the returned model to the view. This works, sometimes (small projects, etc...), but it isn't exactly great when projects start to expand and testing becomes useful.