title: Entity Framework and SQL Server OUTPUT clause
body: <p>I'd like to use <a href="http://technet.microsoft.com/en-US/library/ms177564%28v=sql.90%29.aspx" rel="nofollow">SQL OUTPUT clause</a> to keep history of the records on my database while I'm using Entity Framework. To achieve this, EF needs to generate the following example for a DELETE statement.</p>
  
  <pre><code>Delete From table1
  output deleted.*, 'user name', getdate() into table1_hist
  Where field = 1234;
  </code></pre>
  
  <p>The table table1_hist has the same columns as table1, with the addition of two columns to store the name of the user who did the action and when it happened. However, EF doesn't seem to have a way to support this SQL Server's clause, so I'm lost on how to implement that.</p>
  
  <p>I looked at EF's source code, and the <strong>DELETE</strong> command is create inside a internal static method <code>(GenerateDeleteSql in System.Data.Entity.SqlServer.SqlGen.DmlSqlGenerator class)</code>, so I can't extend the class to add the behavior I want. It looks like I'll have to rewrite the SQL Server provider based on the existing code, but that is something I'd like to avoid...</p>
  
  <p>So, my question is if there's another option to do this (an extension, for example) or do I have to rewrite this provider?</p>
  
  <p>Thank you.</p>