Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UserManager<User> does not find a existing user in database asp.net core Identity

I have ASP.NET Core 2.1 MVC Application. Also in database I have 1 user in role "Admin",but when I try to get list of users in database it returns an empty list.It normaly returns data from "Roles" and "UserRoles" tables, but is unable to see any data in "Users" table and, consequently I can't use SignInAsync, or PasswordSignInAsync methods. This is my dbContext:

public class AppDbContext : IdentityDbContext<User, Role, string>
{
    public AppDbContext(DbContextOptions<AppDbContext> options):base(options)
    { }

    // ...
}

And here is my Startup:

services.AddDbContext<AppDbContext>(options =>
{
    options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"));
});

services.AddIdentity<User, Role>()
    .AddEntityFrameworkStores<AppDbContext>()
    .AddDefaultTokenProviders();

// ...
like image 415
Nərmin Seyidzadə Avatar asked Oct 21 '25 05:10

Nərmin Seyidzadə


1 Answers

Be sure to have NORMALIZEDUSERNAME and NORMALIZEDEMAIL with the same value on email and username in uppercase.

like image 67
DavidRomo Avatar answered Oct 24 '25 09:10

DavidRomo