title: Entity Framework 6 (code first) entity versioning and auditing
body: <p>I'm looking at using Entity Framework 6.1.1 with SQL Server 2008 R2. </p>
  
  <p>Currently I'm creating my models and database using the code-first EF feature. My basic use-case is to create a journal of all changes to a particular entity (<code>ID</code> is the key column) to help auditors track all changes made and by whom. e.g:</p>
  
  <pre><code>|ID|Version|Created Date|Created By|Modified Date|Modified By|Modify Action| ... (rest of entity fields)
  -------------------------------------------------------------------------------------------------------
  | 4| 12    | 12-Mar-14  | tom      | 20-Feb-15   | jack      | Update      |
  | 4| 11    | 12-Mar-14  | tom      | 14-Feb-15   | jill      | Update      |
  | 4| 1     | 12-Mar-14  | tom      | 12-Mar-14   | tom       | Create      |
  </code></pre>
  
  <p>Does Entity Framework support this type of database scheme? If so, how can I set my models/solution up to facilitate this?</p>
  
  <p>The other alternative I have is by intercepting all calls to the <code>SaveChanges()</code> method on the <code>DbContext</code> and log all database changes into a separate <code>Audit</code> table, but this might make retrieving information more challenging. </p>
  
  <p>Any help on creating audit trails with SQL Server and EF 6 would be greately appreciated. </p>