How to use Roles in ASP.NET Core 2.1?

后端 未结 5 2235
小蘑菇
小蘑菇 2021-02-12 20:31

I\'ve created a test project using:

dotnet new razor --auth Individual --output Test

This creates a Startup.cs that contains:

p         


        
5条回答
  •  误落风尘
    2021-02-12 20:41

    Might help someone else: If you add asp.net identity through scaffolding to an existing project, you'll need to edit the IdentityHostingStartup.cs and change the services there instead of in your startup class:

    services.AddIdentity()
                    .AddDefaultUI()
                    .AddRoles()
                    .AddRoleManager>()
                    .AddDefaultTokenProviders()
                    .AddEntityFrameworkStores();
    

    And then you can use the role manager in your seeding.

提交回复
热议问题