Get all children recursively in Entity Framework Core
If you remove virtual from Children it'll work with Include(e =&gt; e.Children):

  public abstract class RecursiveEntity&lt;TEntity&gt;
    : Entity, IRecursiveEntity&lt;TEntity&gt;
    where TEntity : RecursiveEntity&lt;TEntity&gt;
  {
    public virtual TEntity Parent { get; set; }
    public ICollection&lt;TEntity&gt; Children { get; set; }
  }


The meaning with virtual is to provide lazy loading. If you can't live with that, you'll have to do it manually, as you do.



Alternatively I think, you can add "MultipleActiveResultSets=True" to your connection string.



UPDATE

I seems that EF 6 and EFCore work differently when it comes to Include?

EFCore has the Include() and ThenInclude pattern but that is rather useless for recursive initialization.

When loading manually have you then experimented with the abilities to load navigation properties on each object as in:

public IEnumerable&lt;TEntity&gt; Get&lt;TEntity&gt;(Expression&lt;Func&lt;TEntity, bool&gt;&gt; filter) where TEntity: RecursiveEntity&lt;TEntity&gt;
{
  foreach (TEntity entity in Set&lt;TEntity&gt;().Where(e =&gt; e.Parent == null).Where(filter))
  {
    GetChildren(entity, filter);
    yield return entity;
  }
}

private void GetChildren&lt;TEnity&gt;(TEnity parent, Expression&lt;Func&lt;TEnity, bool&gt;&gt; childFilter) where TEnity : RecursiveEntity&lt;TEnity&gt;
{
  Entry(parent).Collection(e =&gt; e.Children).Query().Where(childFilter).Load();
  // Entry(parent).Reference(e =&gt; e.Parent).Load(); // I think this shouldn't be necessary because loading the children will load the parent on them

  if (parent.Children != null)
  {
    foreach (TEnity child in parent.Children)
    {
      GetChildren(child, childFilter);
    }
  }
}


It should produce the same result as yours, but is maybe a little clearer and in line with the EF concept.