How to add RoleManager in Asp.Net 8.0

Previously I used something like the following:

builder.Services.AddDefaultIdentity<IdentityUser>(
    options => options.SignIn.RequireConfirmedAccount = true)
    .AddRoles<IdentityRole>()
    .AddEntityFrameworkStores<ApplicationDbContext>();

But with the release of Asp.Net 8.0 it is more like this:

builder.Services.AddIdentityApiEndpoints<IdentityUser>()
    .AddRoles<IdentityRole>()
    .AddEntityFrameworkStores<DataContext>();

Obviously this only applies if you’re using the new API Identity framework.