Beispiel #1
0
        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;
                }
            }
        }
Beispiel #2
0
        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);
            }
        }