title: Error when serializing EF Code First 5.0 data in WebAPI Controller
body: <p>I had originally asked this question:
  <a href="https://stackoverflow.com/questions/10038037/how-do-i-resolve-a-specified-include-path-is-not-valid">How Do I Resolve &quot;A specified Include path is not valid&quot;?</a> which was answered, and my .Include() is now working, however, when the serializer tries to work it's magic, I get the following error:</p>
  
  <pre><code>You must write an attribute 'type'='object' after writing the attribute 
  with local name '__type'.
  </code></pre>
  
  <p>Here's what I'm doing to return the data:</p>
  
  <pre><code>var everything = dc.Categories
              .Include(c =&gt; c.Products);
  </code></pre>
  
  <p>My class definitions are fairly straightforward:</p>
  
  <pre><code>public class Category
  {
      public int CategoryId { get; set; }
      public string Title { get; set; }
  
      public virtual ICollection&lt;Product&gt; Products { get; set; }
  }
  
  public class Product
  {
      public int ProductId { get; set; }
      public string Title { get; set; }
  
      public virtual Category Category { get; set; }
  }
  
  public class ProductDataContext : DbContext
  {
      public DbSet&lt;Category&gt; Categories { get; set; }
      public DbSet&lt;Product&gt; Products { get; set; }
  }
  </code></pre>
  
  <p>I also tried removing 'virtual' but then I get circular references. I tried making the setter on ICollection Products private (as suggested here: <a href="http://forums.asp.net/t/1773164.aspx/1" rel="nofollow noreferrer">http://forums.asp.net/t/1773164.aspx/1</a>), which gets the error to clear, but then my products aren't part of the returned JSON.</p>
  
  <p>What do I need to do to get the data to serialize with the categories and their products within? </p>
  
  <p><strong>EDIT</strong>
  Here was the stack trace I was getting:</p>
  
  <pre><code>[SerializationException: Object graph for type &amp;#39;System.Collections.Generic.List`1[[Test.Models.Product, Test.Models, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]&amp;#39; contains cycles and cannot be serialized if reference tracking is disabled.]
  System.Web.Http.WebHost.HttpControllerHandler.EndProcessRequest(IAsyncResult result) +30206
  System.Web.Http.WebHost.HttpControllerHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +10
  System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9478661
  System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp;amp; completedSynchronously) +178
  </code></pre>