Unable to Select Custom User Class in Identity Scaffolding
12:39 19 May 2024

I'm trying to scaffold identity pages (Login and Register) in my ASP.NET Core application. However, when I select the pages and my DbContext class, I cannot select my custom user class, ApplicationUser, because the User Class field is disabled.

Here is my DbContext class definition :

public class ApplicationDbContext : IdentityDbContext

My custom user and role :

public class ApplicationUser : IdentityUser
public class ApplicationRole : IdentityRole

I have references to my ApplicationUser and ApplicationRole classes in the context. Additionally, I attempted to roll back the version of the Microsoft.AspNetCore.Identity.UI package, but the issue persists.

What could be causing the User Class field to be disabled, and how can I enable it to select my custom user class?

i tried manually to replace IdentityUser with ApplicationUser in these files : Register.cshtml.cs and Login.cshtml.cs, but it didn't work and i got this error :

InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Identity.UserManager`1[Microsoft.AspNetCore.Identity.IdentityUser]' while attempting to activate 'MyApp.Web.Areas.Identity.Pages.Account.RegisterModel'.

c# asp.net-core asp.net-core-identity scaffolding