From my book (Programming Entity Framework, 2nd Edition, p.590)
While it’s specific to performance with Entity Framework, I think that it is great advice in general.
From the Horse’s Mouth: Performance Tuning Guidance for Entity Framework
Danny Simmons, who is an architect on the Entity Framework team, gave this great advice on a Channel 9 MSDN podcast he and I participated in together as we were interviewed by Microsoft Sweden’s Dag Konig (http://channel9.msdn.com/posts/buzzfrog/MSDN-Radio-31-Maj–Entity-Framework ):
I give the same recommendation about performance optimization with Entity Framework that I give with any code. Which is: write your code the simplest,
easiest to maintain, most efficient possible way.
And then profile it; find where the problems are and start applying optimizations. And when you do that, you typically will find that there are a set of things you can do to improve performance still using the Entity Framework, and eventually some very small set of cases you may find that the performance is very critical and even after you apply your tricks with entity framework, you need to do something faster than that.
And then you can go to some of the extensibility mechanisms, like writing a stored procedure with hand written sql or those kinds of things to really
optimize those few cases.
And that mix allows you to have very rapid development, easy to maintain code using the entity framework and then in a very few places have very highly tuned code.
Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!