且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

获取 ASP.NET MVC5 身份系统中的所有角色名称

更新时间:2023-02-24 22:58:50

我发现您可以通过 IdentityStore 实例使用 DbContext 并使用井-已知方法 .Set().

I've found that you can use the DbContext via the IdentityStore instance and use the well-known method .Set<T>().

这对我有用:

var identityStore = new IdentityStore();
foreach (var role in identityStore.DbContext.Set<Role>())
{
    Debug.WriteLine(role.Name);
}