protected override void Seed(KitKareDbContext context) { this.userManager = new UserManager <User>(new UserStore <User>(context)); this.SeedRoles(context); this.SeedUsers(context); }
private void SeedUsers(KitKareDbContext context) { if (context.Users.Any()) { return; } this.SeedAdmin(context); this.SeedRegularUsers(context); }
private void SeedRoles(KitKareDbContext context) { if (context.Roles.Any()) { return; } context.Roles.AddOrUpdate(x => x.Name, new IdentityRole("Admin")); context.SaveChanges(); }
private void SeedAdmin(KitKareDbContext context) { var admin = new User { Email = "*****@*****.**", UserName = "******" }; this.userManager.Create(admin, "admin11"); this.userManager.AddToRole(admin.Id, "Admin"); context.SaveChanges(); }
private void SeedRegularUsers(KitKareDbContext context) { for (int i = 0; i < 10; i++) { var user = new User { Email = "*****@*****.**", UserName = "******" + i }; this.userManager.Create(user, "user11"); seededUsersIds.Add(user.Id); } context.SaveChanges(); }