public void Transaction_with_explicit_commit_on_a_local_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 SimpleModelContextForCommit()) { context.Database.Delete(); context.Database.Create(); // Begin a local transaction var transaction = BeginLocalTransaction(context); var product = new Product { Name = "Fanta" }; context.Products.Add(product); context.SaveChanges(); // Commit local transaction transaction.Commit(); CloseEntityConnection(context); } using (var context = new SimpleModelContextForCommit()) { Assert.True(context.Products.Where(p => p.Name == "Fanta").Any()); } }
public void Transaction_with_explicit_commit_on_a_local_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 SimpleModelContextForCommit()) { context.Database.Delete(); context.Database.Create(); // Begin a local transaction var transaction = BeginLocalTransaction(context); var product = new Product { Name = "Fanta" }; context.Products.Add(product); context.SaveChanges(); // Commit local transaction transaction.Commit(); CloseEntityConnection(context); } using (var context = new SimpleModelContextForCommit()) { Assert.True(context.Products.Where(p => p.Name == "Fanta").Any()); } }