Why the Repository Pattern

Published on May 20, 2013 by Jamie Munro

After the incredible reaction to a recent blog post, Entity Framework Beginnerís Guide Done Right, I feel like before writing some more code to further the basic example, Iíll take a step back and explain my beliefs in the repository pattern.

I was really overwhelmed with the reaction; what started with a simple 30 minute blogging effort has turned into something absolutely incredible.† The original post was really a starting point about not placing direct querying and saving to the database mingled with the core code.

Please note, these are my thoughts on the pattern based on current and previous pain points that Iíve/am experiencing and Iíd love to hear others input in making things better.

Read more >

Tags: ASP.NET | Theory | c# | entity framework | repository

Entity Framework Beginnerís Guide Done Right

Published on May 13, 2013 by Jamie Munro

Entity framework is a great ORM provided by Microsoft.† There are a ton of examples of how to get up and running with it really quickly.† The only problem with all of them, is the get you off on the wrong foot.

In all of the EF example guides, the DbContext class is typically deeply embedded into the core of your code.† This of course is great for Entity framework because the effort to change will be next to impossible Ė speaking from experience of course here.

Instead, by making some subtle changes we can integrate Entity framework in a separate layer in case at some later date you wish to replace it.† Of course, you might never need to replace it, but following these simple techniques will allow better segregation of code and even provide simpler unit testing.

Read more >

Tags: ASP.NET | Theory | c# | entity framework