public void Transaction_with_explicit_commit_on_commitable_transaction_can_be_used() { // Since this test actually mutates the database outside of a transaction it needs // to use a special context and ensure that the database is deleted and created // each time the test is run. using (var context = new SimpleModelContextForCommit2()) { context.Database.Delete(); context.Database.Create(); var transaction = BeginCommittableTransaction(context); var product = new Product { Name = "Fanta" }; context.Products.Add(product); context.SaveChanges(); // Commit local transaction transaction.Commit(); CloseEntityConnection(context); } using (var context = new SimpleModelContextForCommit2()) { Assert.True(context.Products.Where(p => p.Name == "Fanta").Any()); } }
public void Transaction_with_explicit_commit_on_commitable_transaction_can_be_used() { // Since this test actually mutates the database outside of a transaction it needs // to use a special context and ensure that the database is deleted and created // each time the test is run. using (var context = new SimpleModelContextForCommit2()) { context.Database.Delete(); context.Database.Create(); var transaction = BeginCommittableTransaction(context); var product = new Product { Name = "Fanta" }; context.Products.Add(product); context.SaveChanges(); // Commit local transaction transaction.Commit(); CloseEntityConnection(context); } using (var context = new SimpleModelContextForCommit2()) { Assert.True(context.Products.Where(p => p.Name == "Fanta").Any()); } }