title: Web API 2 Controller with Entity Framework 6 with Include
body: <p>I created a Web API to connect and update data in a SQL Server using
  Entity Framework 6 (database-first).</p>
  
  <p>I notice when I generate controllers for my table, the <code>Get&lt;XXX&gt;</code> function only returns the table row without including the child rows.</p>
  
  <p>This I can fix using the <code>System.Data.Entity.Include</code> extension method?</p>
  
  <p>However when I did a simple test to retrieve the table row and its associated child rows, I get the response</p>
  
  <blockquote>
    <p>StatusCode: 500, ReasonPhrase: 'Internal Server Error', </p>
  </blockquote>
  
  <p>My code is as follows:</p>
  
  <pre><code>// GET: api/Fields/5
  [ResponseType(typeof(Field))]
  public async Task&lt;IHttpActionResult&gt; GetField(Guid id)
  {
      Field field = await db.Fields.Include(x=&gt;x.Layers).FirstOrDefaultAsync(i =&gt; i.FieldKey == id);
  
      if (field == null)
      {
          return NotFound();
      }
  
      return Ok(field);
  }
  </code></pre>
  
  <p>If I use the original generated code without the Include it works fine.</p>
  
  <p>I've disabled lazy loading and proxy in the <code>DbContext</code> constructor:</p>
  
  <pre><code> this.Configuration.LazyLoadingEnabled = false;
   this.Configuration.ProxyCreationEnabled = false;
  </code></pre>