public void DbEntityEntry_Member_works_for_collections_under_partial_trust()
        {
            using (var context = new SimpleModelContext())
            {
                var category = context.Categories.First();

                var collection = context.Entry(category).Member<ICollection<Product>>("Products");

                Assert.NotNull(collection);
                Assert.IsType<DbCollectionEntry<Category, Product>>(collection);
            }
        }
        public void Setting_current_value_of_reference_nav_prop_to_null_does_nothing_for_an_FK_relationship_if_the_relationship_is_not_loaded_and_legacy_behavior_is_set_on_ObjectContext()
        {
            using (var context = new SimpleModelContext())
            {
                context.Configuration.LazyLoadingEnabled = false;
                ((IObjectContextAdapter)context).ObjectContext.ContextOptions.UseConsistentNullReferenceBehavior = false;

                var product = context.Products.Find(1);
                Assert.NotNull(product.CategoryId);
                Assert.Null(product.Category);

                context.Entry(product).Reference(p => p.Category).CurrentValue = null;

                Assert.NotNull(product.CategoryId);
                Assert.Null(product.Category);
            }
        }
            Setting_current_value_of_reference_nav_prop_to_null_nulls_the_FK_even_if_the_relationship_is_not_loaded()
        {
            using (var context = new SimpleModelContext())
            {
                context.Configuration.LazyLoadingEnabled = false;

                var product = context.Products.Find(1);
                Assert.NotNull(product.CategoryId);
                Assert.Null(product.Category);

                context.Entry(product).Reference(p => p.Category).CurrentValue = null;

                Assert.Null(product.CategoryId);
                Assert.Null(product.Category);

                context.Entry(product).Reference(p => p.Category).Load();

                Assert.Null(product.CategoryId);
                Assert.Null(product.Category);
            }
        }
        public void Setting_current_value_of_reference_nav_prop_works_under_partial_trust()
        {
            using (var context = new SimpleModelContext())
            {
                var product = context.Products.Find(1);
                Assert.Null(product.Category);

                var newCategory = new Category("BeanBags");
                context.Entry(product).Reference(p => p.Category).CurrentValue = newCategory;

                Assert.Equal("BeanBags", product.CategoryId);
                Assert.Same(newCategory, product.Category);
            }
        }