.net core 3.0更改默认身份认证的的表。

    public class ApplicationDbContext : IdentityDbContext
    {
        public ApplicationDbContext(DbContextOptions options)
            : base(options)
        {
        }

        protected override void OnModelCreating(ModelBuilder builder)
        {
            base.OnModelCreating(builder);

            builder.Entity().ToTable("WebUsers");
            builder.Entity().ToTable("WebRoles");
            builder.Entity().ToTable("WebRoleClaims");
            builder.Entity().ToTable("WebUserRoles");
            builder.Entity().ToTable("WebUserLogins");
            builder.Entity().ToTable("WebRoleClaims");
            builder.Entity().ToTable("WebUserTokens");
        }
    }

实体:

.net core 3.0更改默认身份认证的的表。_第1张图片

 

 

    public class WebUser : IdentityUser
    {
        public string NickName { get; set; }
    }
依赖注入。        
services.AddIdentity(options => options.SignIn.RequireConfirmedAccount = true) .AddEntityFrameworkStores();

别忘了cshtml中:

@inject SignInManager SignInManager
@inject UserManager UserManager

 

转载于:https://www.cnblogs.com/yeqifeng2288/p/11452096.html

你可能感兴趣的:(.net core 3.0更改默认身份认证的的表。)