title: How can I log all entities change, during .SaveChanges() using EF code first?
body: <p>I'm using <strong>EF code first</strong>. I'm using a base Repository for all my repositories and an <code>IUnitofWork</code> that inject to the repositories, too:</p>
  
  <pre><code>public interface IUnitOfWork : IDisposable
  {
      IDbSet&lt;TEntity&gt; Set&lt;TEntity&gt;() where TEntity : class;
      int SaveChanges();
  }
  
  public class BaseRepository&lt;T&gt; where T : class
  {
      protected readonly DbContext _dbContext;
      protected readonly IDbSet&lt;T&gt; _dbSet;
  
  
      public BaseRepository(IUnitOfWork uow)
      {
          _dbContext = (DbContext)uow;
          _dbSet = uow.Set&lt;T&gt;();
      }
      //other methods
  }   
  </code></pre>
  
  <p>e.g my <code>OrderRepository</code> is like this:</p>
  
  <pre><code>class OrderRepository: BaseRepository&lt;Order&gt;
  {
      IUnitOfWork _uow;
      IDbSet&lt;Order&gt; _order;
  
      public OrderRepository(IUnitOfWork uow)
          : base(uow)
      {
          _uow = uow;
          _order = _uow.Set&lt;Order&gt;();
      }
      //other methods
  }
  </code></pre>
  
  <p>And I use it in this way:</p>
  
  <pre><code>public void Save(Order order)
  {
          using (IUnitOfWork uow = new MyDBContext())
          {
              OrderRepository repository = new OrderRepository(uow); 
              try
              {
                 repository.ApplyChanges&lt;Order&gt;(order);    
                 uow.SaveChanges();
              }  
  
          } 
  }     
  </code></pre>
  
  <p>Is there any way to log change histories of all entities(include their navigation properties) during <code>.SaveChanges()</code>? I want to log <strong>original values</strong>(before save occurs) and <strong>changed values</strong>(after save occurs). </p>