title: JSON.Net Self referencing loop detected in API Controller
body: <p>Environment:</p>
  
  <ul>
  <li>.net 4.6 1.0.0-rc1-update2</li>
  <li>Entity Framework core rc final.</li>
  </ul>
  
  <p>My API controller is throwing this exception:</p>
  
  <blockquote>
    <p>An unhandled exception was thrown by the application.
    Newtonsoft.Json.JsonSerializationException: Self referencing loop detected for property 'Site' with type 'Blog.Model.Site'. Path '[0].Menus[0]'.</p>
  </blockquote>
  
  <p>How can I implement the fixes suggested here:
  <a href="https://stackoverflow.com/questions/13510204/json-net-self-referencing-loop-detected">JSON.Net Self referencing loop detected</a></p>
  
  <p>As far as I know, EF core does not implement lazy loading or proxy creation.</p>
  
  <p>My controller simply returns the collection generated by this query:</p>
  
  <pre><code>public async Task&lt;List&lt;Site&gt;&gt; GetActiveSites()
  {
      var query = db.Sites.Where(x =&gt; x.Active)
          .Include(x =&gt; x.Menus)
          .ThenInclude(m =&gt; m.MenuContentItems)
          .ThenInclude(x =&gt; x.ContentItem);
  
      return await query.ToListAsync();
  }
  </code></pre>
  
  <p>Where:</p>
  
  <ul>
  <li>Site(1) -  Menu(*)</li>
  <li>Menu(1) - MenuontentItem(*)</li>
  <li>MenuContentItem(*) - ContentItem(1)</li>
  </ul>