Example #1
0
        public static void Initialize(CatalogContext context)
        {
            if (!context.Categories.Any())
            {
                context.Categories.AddRange(GetPreconfiguredCategories());
            }

            context.SaveChanges();

            var categoryLookup = context.Categories.ToDictionary(c => c.Name, c => c.Id);

            if (!context.CatalogItems.Any())
            {
                context.CatalogItems.AddRange(GetPreconfiguredCatalogItems(categoryLookup));
            }

            context.SaveChanges();
        }