public void CanChangeOwnedPropety()
        {
            var delivery1 = new Delivery();

            var a1 = new Address {
                Street = "Street 1"
            };
            var a2 = new Address {
                Street = "Street 2"
            };
            int a1Id = 0;
            int a2Id = 0;

            var addresses = new List <Address> {
                a1, a2
            };

            delivery1.Addresses = addresses;

            using (var ctx = new AppContextTest(true))
            {
                ctx.Deliveries.Add(delivery1);
                ctx.SaveChanges();
                a1Id = (int)ctx.Entry(delivery1.Addresses[0]).Property("Id").CurrentValue;
                a2Id = (int)ctx.Entry(delivery1.Addresses[1]).Property("Id").CurrentValue;
            }

            Assert.NotEqual(default, delivery1.DeliveryId);
        public void CanOperationWithoutLoad()
        {
            var student1 = new Student {
                Name = "Student 1"
            };
            var student2 = new Student {
                Name = "Student 2"
            };
            var student31 = new Student {
                Name = "Student 31"
            };
            var school = new School {
                Name = "School 1", Students = new List <Student> {
                    student1, student2, student31
                }
            };
            var person = new Person {
                Name = "Person 1"
            };

            using (var ctx = new AppContextTest(true))
            {
                ctx.Schools.Add(school);
                ctx.People.Add(person);
                ctx.SaveChanges();
            }

            School savedSchool = null;

            using (var ctx = new AppContextTest())
            {
                savedSchool          = ctx.Schools.Where(s => s.Id == school.Id).Single();
                savedSchool.Students = null;
                var countStudents = ctx.Entry(savedSchool).Collection(s => s.Students).Query().Where(s => s.Name.Contains("1")).Count();
                Assert.Equal(2, countStudents);
                Assert.Empty(savedSchool.Students);//При операциях явной загрузки без загрузки данных(например Count), коллекция будет создана без элемнтов
            }

            using (var ctx = new AppContextTest())
            {
                savedSchool          = ctx.Schools.Where(s => s.Id == school.Id).Single();
                savedSchool.Students = null;
                var countStudents = ctx.People.Count();
                Assert.NotEqual(default, countStudents);