title: Failed to serialize the response in Web API with Json
body: <p>I am working with ASP.NET MVC 5 Web Api. I want consult all my users.</p>
  
  <p>I wrote <code>api/users</code> and I receive this:</p>
  
  <blockquote>
    <p>"The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; charset=utf-8'"</p>
  </blockquote>
  
  <p>In WebApiConfig, already I added these lines:</p>
  
  <pre><code>HttpConfiguration config = new HttpConfiguration();
  config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType);
  config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; 
  </code></pre>
  
  <p>But it still doesn't work.</p>
  
  <p>My function for return data is this:</p>
  
  <pre><code>public IEnumerable&lt;User&gt; GetAll()
  {
      using (Database db = new Database())
      {
          return db.Users.ToList();
      }
  }
  </code></pre>