title: In EF Core, how to solve an Include ThenInclude chain circular reference?
body: <p>Consider the following scenario. I have 3 classes, representing a many-to-many (N-to-N) relationship between Student and Subject:
  <br/>
  <br/></p>
  
  <pre><code>public class Student
  {
      public long Id { get; set; }
      public string Name { get; set; }
      public DateTime Birthday { get; set; }
      public long RegistrationNumber { get; set; }
  
      public virtual ICollection&lt;Grade&gt; Grades { get; set; }
  }
  </code></pre>
  
  <pre><code>public class Grade
  {
      public long Id { get; set; }
      public int Value { get; set; }
  
      public virtual Student Student { get; set; }
      public virtual Subject Subject { get; set; } 
  }
  </code></pre>
  
  <pre><code>public class Subject
  {
      public long Id { get; set; }
      public string Name { get; set; }
  
      public virtual ICollection&lt;Grade&gt; Grades { get; set; }
  }
  </code></pre>
  
  <p><br/>
  I want to retrieve the list of all students, with their grades, for each subject. To do so, I use:</p>
  
  <pre><code>// context being DbContext
  var res = context.Student.Include(s =&gt; s.Grades).ThenInclude(g =&gt; g.Subject);
  </code></pre>
  
  <p>As properties are lazy-loaded, I expected each subject to only contain their "Name" property. However, upon inspection, I found that the "Grades" list is also set, with a list of all the grades assigned to the subject. This, of course, causes an object cycle.
  <br/>
  <br/>
  I want to avoid that circular referencing, i.e. obtain a list where each subject's only set property is "Name". How can I do it?</p>