Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UserManager.CreateAsync is not adding user to the database

I have this seeder class which is called at the end of the Startup.cs file in the Configure method:

public class UserSeeder
{
    private readonly ApplicationDbContext _context;
    private readonly UserManager<ApplicationUser> _userManager;
    public UserSeeder(ApplicationDbContext context, UserManager<ApplicationUser> userManager)
    {
        _context = context;
        _userManager = userManager;
    }

    public async Task Seed()
    {
        if (!await _context.Users.AnyAsync())
        {
            var user = new ApplicationUser()
            {
                UserName = "admin",
                Email = "[email protected]"
            };
            await _userManager.CreateAsync(user, "passwort4admin");
        }
    }
}

The code is executed and I even put a try/catch around the method call but no error happens AND no user is inserted into the database!

Why not?

like image 979
Pascal Avatar asked Mar 17 '17 07:03

Pascal


Video Answer


1 Answers

The problem is the complexity of the password. Add capital and numbers and symbols the issue will solve

like image 168
farham heidari Avatar answered Nov 03 '22 11:11

farham heidari