title: Entity Framework 5 (Code First) Navigation Properties
body: <p>Is it the correct behaviour of entity framework to load all items with the given foreign key for a navigation property before querying/filtering?</p>
  
  <p>For example:</p>
  
  <pre><code>myUser.Apples.First(a =&gt; a.Id == 1 &amp;&amp; !a.Expires.HasValue);
  </code></pre>
  
  <p>Will load all apples associated with that user. (The SQL query doesn't query the ID or Expires fields).</p>
  
  <p>There are two other ways of doing it (which generate the correct SQL) but neither as clean as using the navigation properties:</p>
  
  <pre><code>myDbContext.Entry(myUser).Collection(u =&gt; u.Apples).Query().First(a =&gt; a.Id == 1 &amp;&amp; !a.Expires.HasValue);
  
  myDbContext.Apples.First(a =&gt; a.UserId == myUser.Id &amp;&amp; a.Id == 1 &amp;&amp; !a.Expires.HasValue);
  </code></pre>
  
  <h3>Things I've Checked</h3>
  
  <ul>
  <li>Lazy load is enabled and is not disabled anywhere.</li>
  <li>The navigation properties are <code>virtual</code>.</li>
  </ul>