title: Can LINQ BeginTransaction works with new Context?
body: <p>My project is using Ninject to develop, for example, I wrote 2 functions to Insert or Update to Database</p>
  
  <pre><code>public class PersonRepository : IPersonRepository {
  
      private readonly DbContext _context;
  
      public PersonRepository(DbContext context) {
          _context = context;
  }
  
      public void InsertToDB(Person obj) {
          _context.Persons.Add(obj);
          _context.SaveChanges();
  }   
  
      public void UpdateToDB(Person obj) {
          _context.Persons.Attach(obj);
          _context.SaveChanges();
      }   
  }
  </code></pre>
  
  <p>And in Controller, I declare the same DbContext and using transaction:</p>
  
  <pre><code>public class PersonController : Controller {
  
      private readonly DbContext _context;
      private readonly IPersonRepository _repository;
  
      public PersonController(DbContext context, IPersonRepository repository) {
          _context = context;
          _repository = repository;
      }
  
      public ActionResult Index() {
          return View();
      }
  
      [HttpPost]
      public ActionResult ExecuteToDb(Person person1, Person person2) {
          using (var transaction = _context.Database.BeginTransaction(IsolationLevel.ReadCommitted)) {
              try {
                  _repository.InsertToDB(person1);
                  _repository.UpdateToDB(person2);
  
                  transaction.Commit();
              } catch (Exception) {
                  transaction.RollBack();
              }
          }
      }
  }
  </code></pre>
  
  <p>So if <code>InsertToDB()</code> or <code>UpdateToDB()</code> throw any exception, can transaction rollback?</p>
  
  <p>I worry about it because I think the _context of Controller and Repository are different, I am not able to test it right now, help me, thanks!</p>