title: Include multiple tables with EntityFramework
body: <p>I have 3 tables like below image</p>
  
  <p><a href="https://i.stack.imgur.com/P5UmY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/P5UmY.png" alt="Tables"></a></p>
  
  <p>And I have the entity framework codefirst model on the c# (Auto generated)</p>
  
  <p>I'm trying to get the IEnumerable from entities with included Attachments list of each element and I want those attachments elements included with AttachmentType for each Attachments.</p>
  
  <p>for better demonstration I need:</p>
  
  <pre><code>IEnumerable&lt;Registry&gt; registries = GetTableData();
  string oneofthedesiredname = registries
  .First()
  .Attachments
  .First()
  .AttachmentType.Name; //I want that, this definition works but its null
  </code></pre>
  
  <p>with GetTableData() method is like</p>
  
  <pre><code>public IEnumerable&lt;Registry&gt; GetTableData()
      {
          IQueryable&lt;Registry&gt; _registries = _entities.Registry;
          IEnumerable&lt;Registry&gt; data;
          data = _registries
          .Where(p=&gt;p.IsDeleted==false)
          .Include(p=&gt;p.Attachments.Where(x=&gt;x.IsDeleted==false))
          .AsEnumerable();//this query should have change because I cant get Attachmenttypes from this            
          return data;
      }
  </code></pre>
  
  <p>Thank you all, your helps are appreciated.</p>