title: Entity Framework Code First - Reducing round trips with .Load() and .Local
body: <p>I'm setting up a new application using Entity Framework Code Fist and I'm looking at ways to try to reduce the number of round trips to the SQL Server as much as possible.</p>
  
  <p>When I first read about the .Local property <a href="http://blogs.msdn.com/b/adonet/archive/2011/02/01/using-dbcontext-in-ef-feature-ctp5-part-7-local-data.aspx" rel="nofollow">here</a> I got excited about the possibility of bringing down entire object graphs early in my processing pipeline and then using .Local later without ever having to worry about incurring the cost of extra round trips.</p>
  
  <p>Now that I'm playing around with it I'm wondering if there is any way to take down all the data I need for a single request in one round trip. If for example I have a web page that has a few lists on it, news and events and discussions. Is there a way that I can take down the records of their 3 unrelated source tables into the DbContext in one single round trip? Do you all out there on the interweb think it's perfectly fine when a single page makes 20 round trips to the db server? I suppose with a proper caching mechanism in place this issue could be mitigated against. </p>
  
  <p>I did run across a <a href="https://msmvps.com/blogs/matthieu/archive/2010/07/09/entity-framework-4-and-mutiresultset-execute-multiple-queries-on-only-one-db-access.aspx" rel="nofollow">couple</a> of <a href="http://blog.cincura.net/232079-multiquery-more-queries-in-one-batch-in-entity-framework-using-linq/" rel="nofollow">cracks</a> at returning multiple results from EF queries in one round trip but I'm not sure the complexity and maturity of these kinds of solutions is worth the payoff.</p>
  
  <p>In general in terms of composing datasets to be passed to MVC controllers do you think that it's best to simply make a separate query for each set of records you need and then worry about much of the performance later in the caching layer using either the <a href="http://archive.msdn.microsoft.com/EFProviderWrappers" rel="nofollow">EF Caching Provider</a> or asp.net caching?</p>