title: EF Core 6 tree-like structure include properties
body: <pre class="lang-cs prettyprint-override"><code>public class Item
  {
      public string Id { get; set; }
      
      public Item Parent { get; set; }
      public string ParentId { get; set; }
      
      public ICollection&lt;Item&gt; Children { get; set; }
  }
  
  public class TaskExecutionContextConfiguration : IEntityTypeConfiguration&lt;Item&gt;
  {
      /// &lt;inheritdoc/&gt;
      public void Configure(EntityTypeBuilder&lt;Item&gt; builder)
      {
          builder.HasKey(item =&gt; item.Id);
  
          builder
              .HasOne(item =&gt; item.Parent)
              .WithMany(item =&gt; item.Children)
              .HasForeignKey(item =&gt; item.ParentId);
      }
  }
  </code></pre>
  <p>Hi,</p>
  <p>I have classes and configuration like shown above. When you query with <code>Include(i =&gt; i.Children)</code>, you will get only the first set of children of the instance. If check the children of the children, it is not included.</p>
  <p>If I use <code>Include(i =&gt; i.Children).ThenInclude(i =&gt; i.Children)</code>, I get one more level of children, but then it stops again.</p>
  <p>How can I get all children in this tree included?</p>