title: Auto-generated controllers by Entity Framework (Web API 2)
body: <p>Does anyone have an idea why auto-generated controllers in ASP.NET Web API by Entity Framework don't check if given entities are null. Here's an example what you get when you auto-generate a controller for an entity.</p>
  
  <p>If you try posting no content at the controller, a null pointer exception gets thrown. A check against a null value should be there by default, if you ask me. Any ideas why this isn't in ASP.NET Web API 2 by default?</p>
  
  <pre><code>// POST: api/MyEntity
  [ResponseType(typeof(MyEntity))]
  public IHttpActionResult PostMyEntity(MyEntity entity)
  {
      if (!ModelState.IsValid)
      {
          return BadRequest(ModelState);
      }
  
      _db.MyEntities.Add(entity);
      _db.SaveChanges();
  
      return CreatedAtRoute("DefaultApi", new { id = entity.Id }, entity);
  }
  </code></pre>