public void Can_insert_update_and_delete_when_tph_inheritance() { using (var context = CreateContext()) { var customer = new SpecialCustomer(); Assert.Equal(0, context.Set<SpecialCustomer>().Count()); // Insert context.Set<SpecialCustomer>().Add(customer); context.SaveChanges(); Assert.Equal(1, context.Set<SpecialCustomer>().Count()); // Update customer.Points = 1; context.SaveChanges(); Assert.Equal(1, context.Set<SpecialCustomer>().Select(c => c.Points).First()); // Delete context.Set<SpecialCustomer>().Remove(customer); context.SaveChanges(); Assert.Equal(0, context.Set<SpecialCustomer>().Count()); } }
public void Can_insert_update_and_delete_when_tpt_inheritance() { ExtendedSqlAzureExecutionStrategy.ExecuteNew( () => { using (new TransactionScope()) { using (var context = CreateContext()) { var customer = new SpecialCustomer(); Assert.Equal(0, context.Set<SpecialCustomer>().Count()); // Insert context.Set<SpecialCustomer>().Add(customer); context.SaveChanges(); Assert.Equal(1, context.Set<SpecialCustomer>().Count()); // Update customer.Points = 1; context.SaveChanges(); Assert.Equal(1, context.Set<SpecialCustomer>().Select(c => c.Points).First()); // Delete context.Set<SpecialCustomer>().Remove(customer); context.SaveChanges(); Assert.Equal(0, context.Set<SpecialCustomer>().Count()); } } }); }