private void CreateProducts(ProdutsDbContext dbContext) { for (int i = 0; i <= 10; i++) { dbContext.Add(new Product() { Id = i + 4, Name = Faker.Name.FullName(), Inventory = Faker.Number.RandomNumber(15, 150), Price = (decimal)Faker.Number.Double() }); } dbContext.SaveChanges(); }
private void SeedData() { if (!dbContext.Products.Any()) { dbContext.Products.Add(new Db.Data.Product() { Id = 1, Name = "Keyboard", Price = 20, Inventory = 100 }); dbContext.Products.Add(new Db.Data.Product() { Id = 2, Name = "Mouse", Price = 5, Inventory = 300 }); dbContext.Products.Add(new Db.Data.Product() { Id = 3, Name = "Monitor", Price = 150, Inventory = 254 }); dbContext.Products.Add(new Db.Data.Product() { Id = 4, Name = "CPU", Price = 200, Inventory = 156 }); dbContext.SaveChanges(); } }