title: ASP.NET MVC: How to view query executed by SaveChanges (on the ADO.NET Entity Data Model)
body: <p>When trying to add a few items to the database I'm getting this error:</p>
  
  <blockquote>
    <p>UpdateException was unhandled by user code<br>
    <em>An error occurred while updating the entries. See the InnerException for details.</em></p>
  </blockquote>
  
  <p>The InnerException contains this:</p>
  
  <blockquote>
    <p>{"Column count doesn't match value count at row 1"}</p>
  </blockquote>
  
  <p>I can't see anything wrong with the objects I'm trying to add, all the required values are filled.<br>
  Is there any way of viewing the query that causes the problem?</p>
  
  <p>The method's code, if required:</p>
  
  <pre><code>    [AcceptVerbs(HttpVerbs.Post)]
      public ActionResult LaadVerrichtingenIn() {
          int[] intArray = Array.ConvertAll&lt;String, int&gt;(Request.Form["selectedObjects"].Split(','), new Converter&lt;String, int&gt;(Convert.ToInt32));
          List&lt;Verrichting&gt; gekozenVerrichtingen = new List&lt;Verrichting&gt;();
  
          foreach(int i in intArray){
              base._entities.AddToVerrichtingSet(((Dictionary&lt;int, Verrichting&gt;)Session["ingelezenVerrichtingen"])[i]);
              gekozenVerrichtingen.Add(((Dictionary&lt;int, Verrichting&gt;)Session["ingelezenVerrichtingen"])[i]);
          }
          Session["ingelezenVerrichtingen"] = null;
          base._entities.SaveChanges(); //Exception occurs here
  
          return View("IngeladenVerrichtingen");
      }
  </code></pre>
  
  <p>base._entities is an ADO.NET Entity Data Model.</p>
  
  <p>Thanks</p>