I want to remove the UserName field from the IdentityUser
I don't want to use it
1 Answer
You need to create a class that inherits from IdentityUser
public class ApplicationUser : IdentityUser
{
public override string UserName
{
get => null;
set {}
}
}
Register it like
builder.Services.AddIdentity<ApplicationUser, IdentityRole>(options =>
{
options.User.RequireUniqueEmail = true;
})
It will work.
The only thing you need is to manually drop the column from the database, or modify the DBContext like
builder.Entity<ApplicationUser>()
.Ignore(u => u.UserName);
Hope it helps