private List<Product> CreateTestProductsWithProductInfo(NorthwindDbContext context)
        {
            // Create test entities
            var category1 = new Category
            {
                CategoryName = "Test Category 1b"
            };
            var info1 = context.ProductInfos
                .Single(pi => pi.ProductInfoKey1 == ProductInfo1A
                    && pi.ProductInfoKey2 == ProductInfo1B);
            var product1 = new Product
            {
                ProductName = "Test Product 1b",
                UnitPrice = 10M,
                Category = category1,
                ProductInfo = info1
            };

            // Persist entities
            context.Products.Add(product1);
            context.SaveChanges();

            // Detach entities
            var objContext = ((IObjectContextAdapter)context).ObjectContext;
            objContext.Detach(product1);

            // Clear reference properties
            product1.Category = null;
            product1.ProductInfo = null;

            // Return entities
            return new List<Product> { product1 };
        }
        private List<Employee> CreateTestEmployees(NorthwindDbContext context)
        {
            // Create test entities
            var area1 = new Area { AreaName = "Northern" };
            var area2 = new Area { AreaName = "Southern" };
            var territory1 = context.Territories.Single(t => t.TerritoryId == TestTerritoryId1);
            var territory2 = context.Territories.Single(t => t.TerritoryId == TestTerritoryId2);
            var territory3 = context.Territories.Single(t => t.TerritoryId == TestTerritoryId3);
            territory1.Area = area1;
            territory2.Area = area2;
            territory3.Area = area2;
            var employee1 = new Employee
            {
                FirstName = "Test",
                LastName = "Employee1",
                City = "San Fransicso",
                Country = "USA",
                Territories = new List<Territory> { territory1, territory2 }
            };
            var employee2 = new Employee
            {
                FirstName = "Test",
                LastName = "Employee2",
                City = "Sacramento",
                Country = "USA",
                Territories = new List<Territory> { territory2, territory3 }
            };

            // Persist entities
            context.Employees.Add(employee1);
            context.Employees.Add(employee2);
            context.SaveChanges();

            // Detach entities
            var objContext = ((IObjectContextAdapter)context).ObjectContext;
            objContext.Detach(employee1);
            objContext.Detach(employee2);

            // Clear reference properties
            territory1.Area = null;
            territory2.Area = null;
            territory3.Area = null;
            employee1.Territories = new List<Territory> { territory1, territory2 };
            employee2.Territories = new List<Territory> { territory2, territory3 };

            // Return employees
            return new List<Employee> { employee1, employee2 };
        }
        private List<Product> CreateTestProductsWithPromos(NorthwindDbContext context)
        {
            // Create test entities
            var promo1 = new HolidayPromo
            {
                PromoId = 1,
                PromoCode = "THX",
                HolidayName = "Thanksgiving"
            };
            var category1 = new Category
            {
                CategoryName = "Test Category 1a"
            };
            var product1 = new Product
            {
                ProductName = "Test Product 1a",
                UnitPrice = 10M,
                Category = category1,
                HolidayPromo = promo1
            };

            // Persist entities
            context.Products.Add(product1);
            context.SaveChanges();

            // Detach entities
            var objContext = ((IObjectContextAdapter)context).ObjectContext;
            objContext.Detach(product1);

            // Clear reference properties
            product1.Category = null;
            product1.HolidayPromo = null;

            // Return entities
            return new List<Product> { product1 };
        }
        private List<Order> CreateTestOrders(NorthwindDbContext context)
        {
            // Create test entities
            var category1 = new Category
            {
                CategoryName = "Test Category 1"
            };
            var category2 = new Category
            {
                CategoryName = "Test Category 2"
            };
            var product1 = new Product
            {
                ProductName = "Test Product 1",
                UnitPrice = 10M,
                Category = category1
            };
            var product2 = new Product
            {
                ProductName = "Test Product 2",
                UnitPrice = 20M,
                Category = category2
            };
            var product3 = new Product
            {
                ProductName = "Test Product 3",
                UnitPrice = 30M,
                Category = category2
            };
            var customer1 = context.Customers
                .Include(c => c.Territory)
                .Include(c => c.CustomerSetting)
                .Single(c => c.CustomerId == TestCustomerId1);
            var customer2 = context.Customers
                .Include(c => c.Territory)
                .Include(c => c.CustomerSetting)
                .Single(c => c.CustomerId == TestCustomerId1);
            var detail1 = new OrderDetail {Product = product1, Quantity = 11, UnitPrice = 11M};
            var detail2 = new OrderDetail {Product = product2, Quantity = 12, UnitPrice = 12M};
            var detail3 = new OrderDetail {Product = product2, Quantity = 13, UnitPrice = 13M};
            var detail4 = new OrderDetail {Product = product3, Quantity = 14, UnitPrice = 14M};
            var order1 = new Order
            {
                OrderDate = DateTime.Today,
                Customer = customer1,
                OrderDetails = new List<OrderDetail>
                {
                    detail1,
                    detail2,
                }
            };
            var order2 = new Order
            {
                OrderDate = DateTime.Today,
                Customer = customer2,
                OrderDetails = new List<OrderDetail>
                {
                    detail3,
                    detail4,
                }
            };

            // Persist entities
            context.Orders.Add(order1);
            context.Orders.Add(order2);
            context.SaveChanges();

            // Detach entities
            var objContext = ((IObjectContextAdapter) context).ObjectContext;
            objContext.Detach(order1);
            objContext.Detach(order2);

            // Clear reference properties
            product1.Category = null;
            product2.Category = null;
            product3.Category = null;
            customer1.Territory = null;
            customer2.Territory = null;
            customer1.CustomerSetting = null;
            customer2.CustomerSetting = null;
            detail1.Product = null;
            detail2.Product = null;
            detail3.Product = null;
            detail4.Product = null;
            order1.OrderDetails = new List<OrderDetail> { detail1, detail2 };
            order2.OrderDetails = new List<OrderDetail> { detail3, detail4 };

            // Return orders
            return new List<Order> {order1, order2};
        }