Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void SeedCategories(ProductShopContext context)
- {
- using (StreamReader file = File.OpenText("../../../categories.json"))
- {
- Category[] categories = JsonConvert.DeserializeObject<Category[]>(file.ReadToEnd());
- foreach (var category in categories)
- {
- context.Categories.AddOrUpdate(category);
- }
- context.SaveChanges();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement