title: Webapi2 returning ef object
body: <p>I have a problem with entity framework object in a webapi project.
  Since 2-3 days ago everything works fine, but now, the api I call always return "Out of memory exception".</p>
  
  <p>Initially I check for the classic "circular reference error" but is not the case.</p>
  
  <p>In the webapi configuration I have this</p>
  
  <pre><code>config.Formatters.JsonFormatter.SerializerSettings.TypeNameHandling = TypeNameHandling.None;
          config.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.None;
          config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
          config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json"));
  </code></pre>
  
  <p>And to return ef object I use function like this</p>
  
  <pre><code>public Contatti GetContatto([FromUri]int id)
      {
          var db=new WebEntities();
          return(db.Contatti.Single(x=&gt;x.IDContatto == id));
      }
  </code></pre>
  
  <p>There's a way to return an ef object (with its subobject) in a json response with webapi2?</p>