public void Deleting_object_when_relationships_have_not_been_all_enumerated_should_not_cause_collection_modified_exception_209773() { if (!_isSqlAzure) { try { ProviderAgnosticConfiguration.SuspendExecutionStrategy = true; using (var context = new HaveToDoContext()) { using (context.Database.BeginTransaction()) { var group = context.ComplexExams.Where(e => e.Code == "group").Single(); var _ = group.Training.Id; context.ComplexExams.Remove(group); // This would previously throw Assert.Equal(EntityState.Deleted, context.Entry(group).State); Assert.Equal(0, group.Exams.Count); context.SaveChanges(); Assert.Equal(EntityState.Detached, context.Entry(group).State); Assert.Equal(0, group.Exams.Count); } } } finally { ProviderAgnosticConfiguration.SuspendExecutionStrategy = false; } } }
public ChangeTrackingProxyTests() { using (var context = new GranniesContext()) { context.Database.Initialize(force: false); } using (var context = new HaveToDoContext()) { context.Database.Initialize(force: false); } }
public ChangeTrackingProxyTests() { using (var context = new GranniesContext()) { context.Database.Initialize(force: false); } using (var context = new HaveToDoContext()) { _isSqlAzure = DatabaseTestHelpers.IsSqlAzure(context.Database.Connection.ConnectionString); if (!_isSqlAzure) { context.Database.Initialize(force: false); } } }
public void Deleting_object_when_relationships_have_not_been_all_enumerated_should_not_cause_collection_modified_exception_209773() { using (var context = new HaveToDoContext()) { var group = context.ComplexExams.Where(e => e.Code == "group").Single(); var _ = group.Training.Id; context.ComplexExams.Remove(group); // This would previously throw Assert.Equal(EntityState.Deleted, context.Entry(group).State); Assert.Equal(0, group.Exams.Count); context.SaveChanges(); Assert.Equal(EntityState.Detached, context.Entry(group).State); Assert.Equal(0, group.Exams.Count); } }