I've prepared a few code snippets that you can use to unlock user accounts or simply create new users from the code.

The code has been tested with Episerver (Optimizely) version 11.

Enjoy!

public void ResetUser(string username, string password)
{
    // unlock the user account and reset password
    using (var store = new UserStore<ApplicationUser>(GetDbContext()))
    {
        var adminUser = store.Users.FirstOrDefault(x => x.UserName == username);
        if (adminUser != null)
        {
            adminUser.PasswordHash = HashPassword(password);
            adminUser.IsLockedOut = false;

            store.UpdateAsync(adminUser).GetAwaiter().GetResult();
        }
    }
}

public void CreateUser(string username, string password, string email)
{
    using (var store = new UserStore<ApplicationUser>(GetDbContext()))
    {
        var applicationUser = new ApplicationUser
        {
            UserName = username,
            PasswordHash = HashPassword(password),
            Email = email,
            EmailConfirmed = true,
            LockoutEnabled = true,
            IsApproved = true,
            SecurityStamp = Guid.NewGuid().ToString()
        };

        store.CreateAsync(applicationUser).GetAwaiter().GetResult();
    }
}

public ApplicationUser FindUserByName(string username)
{
    using (var store = new UserStore<ApplicationUser>(GetDbContext()))
    {
        var user = store.FindByNameAsync(username).GetAwaiter().GetResult();
        return user;
    }
}

public ApplicationUser FindUserByEmail(string email)
{
    using (var store = new UserStore<ApplicationUser>(GetDbContext()))
    {
        var user = store.FindByEmailAsync(email).GetAwaiter().GetResult();
        return user;
    }
}

public void AddUserToRoles(ApplicationUser user, string[] roles)
{
    using (var userStore = new UserStore<ApplicationUser>(GetDbContext()))
    using (var roleStore = new RoleStore<IdentityRole>(GetDbContext()))
    {
        var userRoles = userStore.GetRolesAsync(user).GetAwaiter().GetResult();
        
        foreach (string roleName in roles)
        {
            // check if role exists
            var role = roleStore.FindByNameAsync(roleName).GetAwaiter().GetResult();
            if (role == null)
            {
                roleStore.CreateAsync(new IdentityRole { Name = roleName }).GetAwaiter().GetResult();
            }
            // assign user to role
            if (!userRoles.Contains(roleName))
            {
                userStore.AddToRoleAsync(user, roleName).GetAwaiter().GetResult();
            }
        }
    }
}

private static ApplicationDbContext<ApplicationUser> GetDbContext()
{
    return new ApplicationDbContext<ApplicationUser>("EPiServerDB");
}

private string HashPassword(string password)
{
    var passwordHasher = new PasswordHasher();
    string passwordHash = passwordHasher.HashPassword(password);

    return passwordHash;
}