ASP.NET Identity remove column from AspNetUsers table

后端 未结 5 797
轻奢々
轻奢々 2021-01-31 21:12

When I use ASP.NET Identity first code approach, I want to generate columns in AspNetUsers table in my own way. I don\'t need to have stored multiple columns with null values. I

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-31 21:29

    The short answer is no, not without rolling your own implementation. Or you can wait for them to open source asp.net identity on codeplex. Who knows how long that will take.

    The default implementation includes all of those unused columns (see below).

    // Summary:
    //     Default EntityFramework IUser implementation
    //
    // Type parameters:
    //   TKey:
    //
    //   TLogin:
    //
    //   TRole:
    //
    //   TClaim:
    public class IdentityUser : IUser
        where TLogin : Microsoft.AspNet.Identity.EntityFramework.IdentityUserLogin
        where TRole : Microsoft.AspNet.Identity.EntityFramework.IdentityUserRole
        where TClaim : Microsoft.AspNet.Identity.EntityFramework.IdentityUserClaim
    {
        // Summary:
        //     Constructor
        public IdentityUser();
    
        // Summary:
        //     Used to record failures for the purposes of lockout
        public virtual int AccessFailedCount { get; set; }
        //
        // Summary:
        //     Navigation property for user claims
        public virtual ICollection Claims { get; }
        //
        // Summary:
        //     Email
        public virtual string Email { get; set; }
        //
        // Summary:
        //     True if the email is confirmed, default is false
        public virtual bool EmailConfirmed { get; set; }
        //
        // Summary:
        //     User ID (Primary Key)
        public virtual TKey Id { get; set; }
        //
        // Summary:
        //     Is lockout enabled for this user
        public virtual bool LockoutEnabled { get; set; }
        //
        // Summary:
        //     DateTime in UTC when lockout ends, any time in the past is considered not
        //     locked out.
        public virtual DateTime? LockoutEndDateUtc { get; set; }
        //
        // Summary:
        //     Navigation property for user logins
        public virtual ICollection Logins { get; }
        //
        // Summary:
        //     The salted/hashed form of the user password
        public virtual string PasswordHash { get; set; }
        //
        // Summary:
        //     PhoneNumber for the user
        public virtual string PhoneNumber { get; set; }
        //
        // Summary:
        //     True if the phone number is confirmed, default is false
        public virtual bool PhoneNumberConfirmed { get; set; }
        //
        // Summary:
        //     Navigation property for user roles
        public virtual ICollection Roles { get; }
        //
        // Summary:
        //     A random value that should change whenever a users credentials have changed
        //     (password changed, login removed)
        public virtual string SecurityStamp { get; set; }
        //
        // Summary:
        //     Is two factor enabled for the user
        public virtual bool TwoFactorEnabled { get; set; }
        //
        // Summary:
        //     User name
        public virtual string UserName { get; set; }
    }
    

提交回复
热议问题