public async Task SeedEverything(IdentityDbContext context) { if (appSettings.ApplyDbMigrations) { context.Database.Migrate(); } else { context.Database.EnsureCreated(); } //Seed Data Functions await SeedUser(context); }
public async Task SeedUser(IdentityDbContext context) { var password = new PasswordHasher("123456"); var userList = new List <User> { new User { Id = Guid.NewGuid(), CreatedBy = default(Guid), CreatedDate = DateTime.Now, Email = "*****@*****.**", IsActive = true, IsDeleted = false, Name = "admin", PasswordHash = password.Hash, PasswordSalt = password.Salt, Username = "******" }, new User { Id = Guid.NewGuid(), CreatedBy = default(Guid), CreatedDate = DateTime.Now, Email = "*****@*****.**", IsActive = true, IsDeleted = false, Name = "user", PasswordHash = password.Hash, PasswordSalt = password.Salt, Username = "******" } }; await context.Users.AddRangeAsync(userList); context.SaveChanges(); }
public IdentityDbContextInitilizer(IdentityDbContext context, IOptions <AppSettings> options) { appSettings = options.Value; dbContext = context; }