public void Can_attach() { Customer customer = null; var testData = new EFTestData(Context); testData.Batch(x => customer = x.CreateCustomer()); Context.Detach(customer); Context.Dispose(); using (var scope = new UnitOfWorkScope()) { var repository = new EFRepository<Customer>(); repository.Attach(customer); customer.FirstName = "Changed"; scope.Commit(); } Context = new CodeOnlyContext("SandboxCodeOnly").Context; testData = new EFTestData(Context); customer = testData.Get<Customer>(x => x.CustomerID == customer.CustomerID); Assert.That(customer.FirstName, Is.EqualTo("Changed")); }
public void Can_attach() { Customer customer = null; var testData = new EFTestData(Context); testData.Batch(x => customer = x.CreateCustomer()); Context.Detach(customer); Context.Dispose(); using (var scope = new UnitOfWorkScope()) { var repository = new EFRepository <Customer>(); repository.Attach(customer); customer.FirstName = "Changed"; scope.Commit(); } Context = new CodeOnlyContext("SandboxCodeOnly").Context; testData = new EFTestData(Context); customer = testData.Get <Customer>(x => x.CustomerID == customer.CustomerID); Assert.That(customer.FirstName, Is.EqualTo("Changed")); }