Remove properties from AspNetIdentity IdentityUser

Viewed 117

I have a question, is it possible to modify IdentityUser to remove properties? there are many that I do not want. for example "PhoneNumber" or "Email".

Ty

AspNetUsers table IdentityUser class

1 Answers

Technically no, you cannot remove the properties as they are a part of the builtin package. You can extend, but not modify.

If the issue lies in the database and you want to remove the properties from the tables, yes you can

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
        base.OnModelCreating(modelBuilder);
        modelBuilder.Entity<IdentityUser>().Ignore(c => c.AccessFailedCount)
                                           .Ignore(c=> c.LockoutEnabled)
                                           .Ignore(c=>c.LockoutEndDateUtc)
                                           .Ignore(c=>c.Roles)
                                           .Ignore(c=>c.TwoFactorEnabled);//and so on...

        modelBuilder.Entity<IdentityUser>().ToTable("Users");//to change the name of table.

}

from: https://stackoverflow.com/a/38156276/3712531

Related