title: Cannot Eager Load Entity Framework Child Entities
body: <p>I have implemented a UnitOfWork style method of working and I cannot seem to force an eager load in EntityFramework 6. Every time I use the "Include()" syntax it seems to be ignored and the SQL generated will not carry out any form of join which is resulting in a very large amount of SQL being generated as each child entity is having to be queried in the database by its ID.</p>
  
  <p>This is my setup:</p>
  
  <pre><code>public class UnitOfWork : IUnitOfWork
  {
      private readonly SimpleStorageEntities _simpleStorageEntities;
  
      public UnitOfWork()
      {
          _simpleStorageEntities = new SimpleStorageEntities();
      }
  
      public List&lt;T&gt; Query&lt;T&gt;(Expression&lt;Func&lt;T, bool&gt;&gt; predicate, params Expression&lt;Func&lt;T, object&gt;&gt;[] loadOptions) where T : class
      {
          var set = _simpleStorageEntities.Set&lt;T&gt;();
  
          if (loadOptions.Any())
          {
              foreach (var expression in loadOptions)
              {
                  set.Include(expression);
              }
          }
          return set.Where(predicate).ToList();
      }
  }
  </code></pre>
  
  <p>My invocation is as follows:</p>
  
  <pre><code>var entries = _unitOfWork.Query&lt;Entry&gt;(e =&gt; e.TableId == tableId,
              e =&gt; e.AttributeValues);
  </code></pre>
  
  <p>Even though I have specified that I want the AttributeValues loaded, each time one is accessed through a foreach a database call is made. I tried to explicitly specify the Includes in the constructor of the UnitOfWork however this seemingly didn't make any difference.</p>
  
  <p>EDIT: Checked through previous versions on EF just to ensure it isn't version related, no luck</p>
  
  <p>Any thoughts?</p>