title: How do I extend IdentityRole using Web API 2 + AspNet Identity 2
body: <p>I am attempting to extend the AspNet IdentityRole class provided in the Web API 2 (With Individual Accounts) template in the latest version of Visual Studio 2013. When I hit /api/roles it returns an empty array</p>
  
  <p>Identity Models</p>
  
  <pre><code>namespace API.Models
  {
  // You can add profile data for the user by adding more properties to your ApplicationUser class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more.
  public class ApplicationUser : IdentityUser&lt;string, IdentityUserLogin, ApplicationUserRole, IdentityUserClaim&gt;, IUser, IUser&lt;string&gt;
  {
      [NotMapped]
      public virtual UserProfile Profile { get; set; }
  
      public virtual ICollection&lt;ApplicationUserRole&gt; UserRoles { get; set; }
  
      //public virtual List&lt;ApplicationUserRole&gt; ApplicationRoles { get; set; }
  
      public async Task&lt;ClaimsIdentity&gt; GenerateUserIdentityAsync(UserManager&lt;ApplicationUser&gt; manager,
          string authenticationType)
      {
          // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
          ClaimsIdentity userIdentity = await manager.CreateIdentityAsync(this, authenticationType);
          // Add custom user claims here
          return userIdentity;
      }
  }
  
  public class ApplicationRole : IdentityRole&lt;string, ApplicationUserRole&gt;
  {
      public ApplicationRole() : base() { }
  
  }
  
  public class ApplicationUserRole : IdentityUserRole&lt;string&gt;
  {
      public ApplicationUserRole()
          : base()
      { }
  
      public virtual ApplicationRole Role { get; set; }
  }
  
  public class ApplicationDbContext : IdentityDbContext&lt;ApplicationUser,ApplicationRole,string,IdentityUserLogin,ApplicationUserRole,IdentityUserClaim&gt; 
  
  {
  
       public ApplicationDbContext()
          : base("DefaultConnection")
      {
          base.Configuration.ProxyCreationEnabled = false;
      }
  
       public static ApplicationDbContext Create()
      {
          return new ApplicationDbContext();
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Identity Config</p>
  
  <pre><code>namespace API
  {
  // Configure the application user manager used in this application. UserManager is defined in ASP.NET Identity and is used by the application.
  
  public class ApplicationUserManager : UserManager&lt;ApplicationUser, string&gt;
  {
      public ApplicationUserManager(IUserStore&lt;ApplicationUser&gt; store)
          : base(store)
      {
      }
  
      public static ApplicationUserManager Create(IdentityFactoryOptions&lt;ApplicationUserManager&gt; options,
          IOwinContext context)
      {
          var manager = new ApplicationUserManager(new UserStore&lt;ApplicationUser&gt;(context.Get&lt;ApplicationDbContext&gt;()));
  
          // Configure validation logic for usernames
          manager.UserValidator = new UserValidator&lt;ApplicationUser&gt;(manager)
          {
              AllowOnlyAlphanumericUserNames = false,
              RequireUniqueEmail = true
          };
          // Configure validation logic for passwords
          manager.PasswordValidator = new PasswordValidator
          {
              RequiredLength = 6,
              RequireNonLetterOrDigit = true,
              RequireDigit = true,
              RequireLowercase = true,
              RequireUppercase = true,
          };
          IDataProtectionProvider dataProtectionProvider = options.DataProtectionProvider;
          if (dataProtectionProvider != null)
          {
              manager.UserTokenProvider =
                  new DataProtectorTokenProvider&lt;ApplicationUser&gt;(dataProtectionProvider.Create("ASP.NET Identity"));
          }
          return manager;
      }
  }
  
  
  
  public class ApplicationRoleManager : RoleManager&lt;ApplicationRole, string&gt;
  {
      public ApplicationRoleManager(IRoleStore&lt;ApplicationRole, string&gt; store)
          : base(store)
      {
      }
  
      public static ApplicationRoleManager Create(IdentityFactoryOptions&lt;ApplicationRoleManager&gt; options,
          IOwinContext context)
      {
          var manager = new ApplicationRoleManager(new RoleStore&lt;ApplicationRole&gt;(context.Get&lt;ApplicationDbContext&gt;()));
          return manager;
      }
  
  }
  </code></pre>
  
  <p>}</p>