title: Entity Framework Code First Select Item Based on Relationship
body: <p>I have 2 tables that were set up with Entity Framework 6 using code first. </p>
  
  <p><strong>Member Table</strong></p>
  
  <ol>
  <li>MemberID</li>
  <li>FirstName</li>
  <li>LastName</li>
  <li>Email</li>
  </ol>
  
  <p><strong>Member Addresses</strong></p>
  
  <ol>
  <li>MemberAddressID</li>
  <li>Address</li>
  <li>City</li>
  <li>State</li>
  <li>Zip</li>
  <li>IsDeleted</li>
  <li>MemberID</li>
  </ol>
  
  <p>What I'm trying to accomplish is grab a member entity, and let EF auto grab the relation to Member Addresses, which so far is working fine. </p>
  
  <p>What I'm stuck on is that EF is grabbing all objects from the Member Addresses table even though I've marked some of the records IsDeleted = true. </p>
  
  <p>Here is my query, not really sure what I'm doing wrong. </p>
  
  <pre><code>return GenRepo.Context.Member.Where(x =&gt; x.MemberID == MemberID &amp;&amp; x.MemberAddresses.Any(y =&gt; y.IsDeleted == false)).FirstOrDefault();
  </code></pre>