title: Entity Framework 6 Include() does not really includes the navigation property
body: <p>I have a simple but at the same time an annoying problem. I try to create generic methods for CRUD operations in Business Layer. There is a specific requirement that all navigation properties should be included for some objects and should be returned as a List.</p>
  
  <p>Please look at the both code samples:</p>
  
  <pre><code>List&lt;Event&gt; list;
  using (var db = new DbContext())
  {
      db.Configuration.ProxyCreationEnabled = false;
      var dbQuery = db.Set&lt;Event&gt;();
      list = dbQuery.Include(x =&gt; x.Location).ToList();
  }
  </code></pre>
  
  <p>Above code snippet works fine as expected.</p>
  
  <pre><code>List&lt;Event&gt; list;
  using (var db = new DbContext())
  {
      db.Configuration.ProxyCreationEnabled = false;
      var dbQuery = db.Set&lt;Event&gt;();
      // foreach(var np in navigationProperties) -&gt; I omitted this block and only included one property to keep it simple
      dbQuery.Include(x =&gt; x.Location);
      list = dbQuery.ToList();
  }
  </code></pre>
  
  <p>Above code snippet does not work (was working fine in EF4). The reason why I need the second block is that navigation properties which should always be included are stored in a seperate manifest file and via foreach loop these are included depending on object type.</p>
  
  <p>It seems both are very same but actually not. I could not find a solution and need your help. </p>
  
  <p>Thank you in advance for any comment/feedback.</p>
  
  <p>UPDATE (with SOLUTION): Thanks to Masoud'd feedback, the problem is now clear. if you call dbQuery.Include(...) then the sql command in the dbQuery is NOT changed. Therefore you need to assign the result to another query. I provide the following code which works fine for others who have the same problem:</p>
  
  <pre><code>List&lt;Event&gt; list;
  using (var db = new DbContext())
  {
      db.Configuration.ProxyCreationEnabled = false;
      var dbQuery = db.Set&lt;Event&gt;();
      DbQuery&lt;Event&gt; query = null;
      foreach (var navigationProperty in navigationProperties)
      {
          if(query==null)
              query = dbQuery.Include(navigationProperty);
          else
              query = query.Include(navigationProperty);
      }
      if (query != null) list = query.ToList();
  }
  </code></pre>