【问题标题】:How to add column in AspnetUser in ASP.NET Core 3.1?如何在 ASP.NET Core 3.1 的 AspnetUser 中添加列?
【发布时间】:2020-01-14 10:10:42
【问题描述】:

我创建了一个具有以下属性的类应用程序用户:

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

我已将启动更新为:

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

但是我的迁移是空的。我希望 RandomPassword 作为 AspNetUser 表的列。

【问题讨论】:

    标签: c# asp.net-mvc asp.net-core asp.net-identity asp.net-core-3.1


    【解决方案1】:

    您可能在 DbContext 中缺少此定义

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

    【讨论】:

      猜你喜欢
      • 2022-12-06
      • 2021-03-02
      • 1970-01-01
      • 2022-01-09
      • 2021-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多