title: Entity Framework 6 - How can I view the SQL that will be generated for an insert before calling SaveChanges
body: <p>In Entity Framework 6, is it possible to view the SQL that will be executed for an <strong>insert</strong> <em>before</em> calling SaveChanges? </p>
  
  <pre><code>using (var db = new StuffEntities()){
      db.Things.Add(new Thing({...});
      //can I get the SQL insert statement at this point?
      db.SaveChanges();
  }
  </code></pre>
  
  <p>I'm familiar with how to get the generated SQL for a <strong>query</strong> before execution like so:</p>
  
  <pre><code>var query = db.Thing.Where(x =&gt; x.ID == 9);
  Console.WriteLine(query.ToString());
  //this prints the SQL select statement
  </code></pre>
  
  <p>The query returns an IQueryable&lt;> whereas an insert returns a DbSet and calling ToString on a DbSet just prints the standard object name. </p>