title: Why include a Repo.SaveChanges() method in a repository?
body: <p>I'm in a discussion with another developer about whether or not to have a <code>repo.SaveChanges()</code> method exposed in our Entity Framework 5 repository.</p>
  
  <p>We're considering having a repo that automatically saves changes like this (quick and dirty example):</p>
  
  <pre><code>public class Repo {
      private OurEfContext _context = new OurEfContext();
  
      public void PersistCustomer(Customer cust)
      {
          // update customer code here
          _context.SaveChanges(); //  &lt;-- is this okay?
      }
  }
  </code></pre>
  
  <p>The other option we're considering is to expose a separate Repo.PersistChanges() method like this:</p>
  
  <pre><code>public class Repo {
      private OurEfContext _context = new OurEfContext();
  
      public void PersistCustomer(Customer cust)
      {
          // update customer code here
          // no call to _context.SaveChanges();
      }
  
      public void PersistChanges()
      {
          _context.SaveChanges();
      }
  }
  </code></pre>
  
  <p>Most examples that I have seen use the second pattern. Is one pattern more 'correct' than the other?</p>