title: Best way to show DB error message when a "Delete" hits a DB constraint
body: <p>I am learning MVC3 and EF4.1 . I am currently experimenting with Database first EF with the new the TT4 generator to generate lean data classes. I have generated a CRUD controller, and have come across the issue of how best to display DB constraint messages in the View. </p>
  
  <p>My code is so far:</p>
  
  <pre><code>    [HttpPost]
      public ActionResult Delete(Guid id, aspnet_Users User)
      {
          string errorMessage = string.Empty;
          try
          {
              // TODO: Add delete logic here
              db.Entry(User).State = System.Data.EntityState.Deleted;
              db.SaveChanges();
              return RedirectToAction("Index");
          }
          catch(Exception err)
          {
              return Content(err.InnerException.StackTrace);
              //return View();
          }
      }
  </code></pre>
  
  <p>Any help greatly appreciated.</p>
  
  <p>Ed</p>