How to Seed Users and Roles with Code First Migration using Identity ASP.NET Core

前端 未结 10 1543
离开以前
离开以前 2020-12-04 10:12

I have created a new clean asp.net 5 project (rc1-final). Using Identity Authentication I just have the ApplicationDbContext.cs with the following code:

publ         


        
10条回答
  •  渐次进展
    2020-12-04 11:05

    The following line create the entry in the AspNetRoles table but does not populate the NormalizedName column.

    Substitute with the following for this column to be populated:

    RoleManager roleManager = serviceProvider.GetService>();
    roleManager.CreateAsync(new IdentityRole(role));
    

提交回复
热议问题