.net Identity 2.0 不返回角色

.net Identity 2.0 not returning roles

我已经使用本教程 http://bitoftech.net/2014/06/01/token-based-authentication-asp-net-web-api-2-owin-asp-net-identity/ 获得了 .net 身份会员平台的介绍...我了解了它 运行 好的。但是,我去扩展了我的角色,现在在我进行身份验证后,没有返回任何角色(只有一个空数组)......请参见下面的代码:

不确定我在这里做错了什么...任何帮助将不胜感激! 谢谢

您需要删除这些行

    // Change these from IdentityRole to ApplicationRole:
//EntityTypeConfiguration<ApplicationRole> entityTypeConfiguration1 =
   // modelBuilder.Entity<ApplicationRole>().ToTable("AspNetRoles");

//entityTypeConfiguration1.Property((ApplicationRole r) => r.Name).IsRequired();

然后在原处添加

  base.OnModelCreating(modelBuilder);

您仍将使用 ApplicationRole 将表作为 AspNetRoles 和 AspNetUsers,因为它是从 IdentityRole 继承的