title: Entity Framework and SQL Server Savepoints
body: <p>I asked a <a href="https://stackoverflow.com/questions/6987679/nested-transactions-in-net">different question</a> about Nested Transactions and the answer to my question educated me enough to help me realize I was asking the question poorly. So here's a better question.</p>
  
  <p><strong>How can I effectively implement SQL Server Savepoints (<a href="http://msdn.microsoft.com/en-us/library/ms378414%28v=SQL.105%29.aspx" rel="nofollow noreferrer">link 1</a>, <a href="http://fgheysels.blogspot.com/2006/11/nested-transactions-in-sql-server.html" rel="nofollow noreferrer">link 2</a>) with a DAL built upon Entity Framework 4.0?</strong></p>
  
  <p>I would LIKE to write the following code and have it work in a way that SQL Server's SAVEPOINTS</p>
  
  <pre><code>public void Bar()
  {
    using (var ts = new TransactionScope())
    {
      var ctx = new Context();
      DoSomeStuff(ctx);
  
      bool isSuccessful;
  
      using (var spA = new SavePoint("A")) // &lt;-- this object doesn't really exist, I don't think
      {
        isSuccessful = DoSomeOtherStuff(ctx);
        if (isSuccessful)
          spA.Complete(); // else rollback bo prior to the beginning of this using block
      }
  
      Log(ctx, isSuccessful);
  
      ts.Complete();
    }
  }
  </code></pre>
  
  <p>Is there such a way to do anything even close to resembling this, or something else that plays nicely with EF4? (we use custom self-tracking POCO entities)</p>