private void SeedDb() { using var context = new JewelryStoreDbContext(_dbContextOptions); _userRoles = new List <UserRole> { new UserRole { Id = Guid.NewGuid(), CreatedOn = DateTime.Now, Name = "Privilaged", IsActive = true }, new UserRole { Id = Guid.NewGuid(), CreatedOn = DateTime.Now, Name = "Regular", IsActive = true } }; _discounts = new List <Discount> { new Discount { Id = Guid.NewGuid(), CreatedOn = DateTime.Now, DiscountPer = 2, IsActive = true, UserRoleId = _userRoles.First().Id }, new Discount { Id = Guid.NewGuid(), CreatedOn = DateTime.Now, DiscountPer = 0, IsActive = true, UserRoleId = _userRoles.Skip(1).First().Id } }; context.AddRange(_userRoles); context.AddRange(_discounts); context.SaveChanges(); }
private void SeedDb() { using var context = new JewelryStoreDbContext(_dbContextOptions); _userRoles = new List <UserRole> { new UserRole { Id = Guid.NewGuid(), CreatedOn = DateTime.Now, Name = "Privilaged", IsActive = true }, new UserRole { Id = Guid.NewGuid(), CreatedOn = DateTime.Now, Name = "Regular", IsActive = true } }; _users = new List <User> { new User { Id = Guid.NewGuid(), CreatedOn = DateTime.Now, Name = "Abby", Password = "******", IsActive = true, UserRoleId = _userRoles.First().Id }, new User { Id = Guid.NewGuid(), CreatedOn = DateTime.Now, Name = "Barack", Password = "******", IsActive = true, UserRoleId = _userRoles.Skip(1).First().Id }, }; context.AddRange(_userRoles); context.AddRange(_users); context.SaveChanges(); }