Store does not implement IUserRoleStore ASP.NET Core Identity

后端 未结 3 1154
孤街浪徒
孤街浪徒 2021-02-19 03:04

I\'m using ASP.NET Core 2.1 Identity. I\'ve overridden IdentityUser because I need to add some additional properties on the user.

In Startup.cs

servic         


        
3条回答
  •  故里飘歌
    2021-02-19 03:26

    In Startup.cs, I was missing AddRoles so

    services.AddDefaultIdentity()
        .AddEntityFrameworkStores();
    

    should be

    services.AddDefaultIdentity()
        .AddRoles()
        .AddEntityFrameworkStores();
    

    Note: The order is critical. AddRoles must come before AddEntityFrameworkStores

提交回复
热议问题