Creating Models

Creating Custom User Model

public class ApplicationUser : IdentityUser<Guid>
{
    [StringLength(255)]
    public string FullName { get; set; } = string.Empty;
}

IdentityUser<TKey> is the core user class in ASP.NET Core Identity. It represents a user account and contains all properties required for authentication, authorisation, and security.

TKey = type of the primary key for a user, by default it is string, but Guid is recommended.

IdentityUser<string>   // default
IdentityUser<Guid>     // recommended
IdentityUser<int>      // rarely used

Main purpose of IdentityUser

It provides:

You don't need to implement these yourself.

It provides properties like:

Id                  // Unique User ID
UserName            // User name for login
Email               // (default) Duplicate Email Ids are allowed.
PasswordHash        // Stores hashed password, NOT plain password.
EmailConfirmed      // Boolean value that indicates if email is verified.
PhoneNumber         // For SMS login & Two-Factor Authentication
TwoFactorEnabled    // Boolean value that enables 2FA login.
LockoutEnd          // Protects from brute-force attacks.
AccessFailedCount   // Counts failed login attempts.
SecurityStamp       // Changes when: Password changes, Logout from all devices