ASP MVC / EF6 - Automatic logging <p>Every table of my database has got 2 columns at the end, which allows logging (User who made the action, and Date of the action). <strong>EDIT :</strong> I use Code-First migrations.<br/> So I would like those two logging columns to be filled automatically :</p> <ol> <li><p>Each time I insert a new entry in my table (using DbContext.[Model].Add(entry))</p></li> <li><p><strong>OR</strong> each time I do a DbContext.SaveChanges() action</p></li> </ol> <p><br /></p> <p><strong>I have considered overriding the DbContext.SaveChanges() method</strong>, but it didn't work out...<br /></p> <p><strong>I have also tried overriding the DbSet Add() method</strong>, to do the log filling action there. For that I have created a CustomDbSet class which inherits from DbSet :</p> <pre><code>public class CustomDbSet&lt;TEntity&gt; : DbSet&lt;TEntity&gt; where TEntity : class { public TEntity Add(TEntity entity) { //Do logging action here return base.Add(entity); } } </code></pre> <p><strong>But this didn't make it neither.</strong> <br /> <strong>EDIT :</strong> What happens with this CustomDbSet is that any DbContext.[Model] returns null, now (instead of being filled with the content of the database table)<br /><br /> I already have the extension method which will do the logging action, but I don't know where to put it so logging would become an "automatic" action..</p> <pre><code>public static void EntityLogCreate&lt;T&gt;(this T model, string userName) where T : LogColumns { model.Create_User = userName; model.Create_Date = DateTime.Now; } </code></pre> <p>Any idea to achieve that ?</p>