public async Task CreateIdentityUsers() { try { foreach (var user in _users) { var identityUser = await _identityProvider.FindUser(user.Key); if (identityUser != null) { return; } _log.Debug($"Adding user: {user.Value} to asp net security."); if (await _identityProvider.CreateUser( user.Key, user.Value.Email, user.Value.Password, confirm: true)) { identityUser = await _identityProvider.FindUser(user.Key); var roles = new string[] { }; if (user.Value.Admin) { roles = new string[] { "Administrator" }; } _log.Debug($"Adding user: {user.Value} to roles: {string.Join(",", roles)} in asp net security."); await _identityProvider.AddToRoles(identityUser.Id, roles); } } } catch (Exception ex) { _log.Error(ex); } }