title: Begin transaction with 2 DBContexts
body: <p>The idea : I am trying to run an insertion to 2 databases using 2 different dbContext, the goal is to allow a role back on the insertion from both QBs in case of an exception from ether one of the insertions.</p>
  
  <p>My code:</p>
  
  <pre><code>using (var db1 = new DbContext1())
  {
      db1.Database.Connection.Open();
      using (var trans = db1.Database.Connection.BeginTransaction())
      {
          //do the insertion into db1
          db1.SaveChanges();
  
          using (var db2 = new DbContext2())
          {
              //do the insertions into db2
              db2.SaveChanges();
          }
          trans.Commit();
      }
  }
  </code></pre>
  
  <p>On the first call to save changes: db1.SaveChanges(); I get an invalid operation exception : sqlconnection does not support parallel transactions</p>
  
  <p>I tried figuring out what does it exactly mean, why does it happen and how to solve it but haven't been able to achieve that.</p>
  
  <p>So my questions are:
  What does it exactly mean? and why do I get this exception?
  How can I solve it?
  Is there a way to use the begin transaction is a different way that won't cause this error?</p>
  
  <p>Also, is this the proper way to use begin transaction or should I do something different?</p>
  
  <p>***For clarification, I am using the db1.Database.Connection.Open(); because otherwise I get an "connection is close" error.</p>