0

I want to remove the UserName field from the IdentityUser I don't want to use it

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.