Implementing recursive property loading in EF Core
<p>I'm on .NET Core 1.1.0, EF Core 1.1.0, VS 2015.</p>

<p>I'm writing a system for posts/comments, and I need a function to load a comment and all of its children and their associated properties. Here's a simplified version of my classes:</p>

<pre><code>public class Comment
{
    public long Id { get; set; }

    public string Content { get; set; }

    public User User { get; set; }

    public ICollection&lt;Comment&gt; Replies { get; set; }
}

public class User
{
    public long Id { get; set; }

    public string Name { get; set; }

    public Avatar Avatar { get; set; }
}

public class Avatar
{
    public string Url { get; set; }
}
</code></pre>

<p>Any given comment can have any number of replies:</p>

<pre><code>-PARENT
    -CHILD 1
    -CHILD 2
        -CHILD 3
    -CHILD 4
    -CHILD 5
        -CHILD 6
            -CHILD 7
</code></pre>

<p>So, given the ID of the parent comment, I need to load the entire tree, including users and their respective avatars. <em>(I have controls elsewhere to make sure these trees don't become unwieldy, I'm not concerned at this point about potentially grabbing way too much data.)</em></p>

<p>The <a href="https://docs.microsoft.com/en-us/ef/core/querying/related-data" rel="noreferrer">Loading Related Data</a> page in the EF Core docs is very helpful, but I'm not sure how to best handle this. I've experimented putting some things together but I just can't conceptualize how to fit it all together. To note again: I'm using EF Core 1.1.0, so I do have access to the functions in the "Explicit loading" section.</p>

<p><strong>How can I load the entire tree of comments given a parent comment's ID?</strong></p>