title: Does the entity framework have the need for prefetch paths?
body: <p>I am converting from one ORM to another (LLBGen Pro to Entity Framework).  In order to properly refactor I need to understand something.  In LLBGen Pro there's a concept called <a href="http://www.llblgen.com/documentation/2.6/Using%20the%20generated%20code/SelfServicing/gencode_prefetchpaths.htm" rel="nofollow">prefetch paths</a>. Prefetch paths exists in order to reduce the number of queries required in cases where lazy loading negatively impacts performance.  In Gen Pro, lets say I have 50 orders and I want to gather the customer related to each order.  With lazy loading I could end up with 51 DB queries.  1 for the orders and 50 more for each customer due to the lazy loading of customers vs just 2 queries with prefetch paths enabled.</p>
  
  <p>My understanding is that entity framework (or perhaps LINQ to SQL) generates the most optimum SQL for the situation.  Is Entity Framework somehow smart enough to optimize the queries in such a case where LLB Gen Pro cannot?  In other words, does entity framework generate the SQL at runtime intelligently where it can "look ahead" and see the need for all customers and generate a single query rather than 50 individual queries?  Or, does EF support some type of "prefetch path" or does this require some advanced custom expression trees...etc?</p>