title: EFCore Linq ThenInclude Two Foreign Keys To Same Table
body: <p>Does anyone see what I am doing wrong?<br>
  <code>ProjectActivityTasks</code> has the <code>UnitOfMeasureId</code> and the <code>ProjectActivityTaskTypeId</code>. With the way it is written, it thinks that <code>UnitOfMeasure</code> goes to <code>ProjectActivityTaskType</code>. It is erroring out on the <code>ThenInclude</code> for <code>UnitOfMeasure</code> saying</p>
  
  <blockquote>
    <p>ProjectActivityTaskType does not contain a definition for UnitOfMeasure</p>
  </blockquote>
  
  <p>which is correct. <code>UnitOfMeasure</code> goes to <code>ProjectActivityTasks</code>. </p>
  
  <p>I was referencing this page but it does not seem to work this way: <a href="https://docs.microsoft.com/en-us/ef/core/querying/related-data" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/ef/core/querying/related-data</a></p>
  
  <pre><code>var qry = await _projectActivityRepository.GetAll()
  .Include(x =&gt; x.ProjectActivityVehicles)
    .ThenInclude(x =&gt; x.Vehicle)
  .Include(x =&gt; x.ProjectActivityTasks)
    .ThenInclude(x =&gt; x.ProjectActivityTaskType)
    .ThenInclude(x =&gt; x.UnitOfMeasure)
  .Where(x =&gt; x.Id == Id &amp;&amp; x.TenantId == (int)AbpSession.TenantId)
  .FirstOrDefaultAsync();
  </code></pre>