简体   繁体   中英

How to add column in AspnetUser in ASP.NET Core 3.1?

I have created a class Application User with following properties:

 public class ApplicationUser:IdentityUser
 {
    public string RandomPassword { get; set; }
 }

And I have updated startup as:

services.AddIdentity<ApplicationUser, IdentityRole>(options => options.SignIn.RequireConfirmedAccount = true)
            .AddEntityFrameworkStores<ApplicationDbContext>().AddDefaultTokenProviders();

But I am getting migration to be empty.I want RandomPassword as column of AspNetUser table.

Your are presumably missing this definition in the DbContext

public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
   // omitted 
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM