public static void Initialize(IServiceProvider serviceProvider) { using (var ctx = new EstimationDBContext(serviceProvider.GetRequiredService <DbContextOptions <EstimationDBContext> >())) { if (ctx.Users.Any()) { return; } ctx.Users.AddRange(new User { Id = 1, FirstName = "Privileged", LastName = "User", Username = "******", Password = "******", Role = Role.Privileged }, new User { Id = 2, FirstName = "Regular", LastName = "User", Username = "******", Password = "******", Role = Role.Regular }); ctx.SaveChanges(); } }
public UserRepository(EstimationDBContext dBContext, IServiceProvider service) { _serviceProvider = service; LoadInitialData(); _dbContext = dBContext; }