title: The foreign key component 'RoleId' is not a declared property on type 'ApplicationUserRole'
body: <p>1.Here is the model creating function</p>
  
  <pre><code>    protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
      {
          modelBuilder.HasDefaultSchema("TEST");
  
          modelBuilder.Entity&lt;ApplicationUserLogin&gt;().Map(c =&gt;
          {
              c.ToTable("UserLogin");
              c.Properties(p =&gt; new
              {
                  p.UserId,
                  p.LoginProvider,
                  p.ProviderKey
              });
          }).HasKey(p =&gt; new { p.LoginProvider, p.ProviderKey, p.UserId });
  
           //Mapping for ApiRole
          modelBuilder.Entity&lt;ApplicationRole&gt;().Map(c =&gt;
          {
              c.ToTable("Role");
              c.Property(p =&gt; p.Id).HasColumnName("RoleId");
              c.Properties(p =&gt; new
              {
                  p.Name
              });
          }).HasKey(p =&gt; p.Id);
          modelBuilder.Entity&lt;ApplicationRole&gt;().HasMany(c =&gt; c.Users).WithRequired().HasForeignKey(c =&gt; c.RoleId);
  
          modelBuilder.Entity&lt;ApplicationUser&gt;().Map(c =&gt;
          {
              c.ToTable("User");
              c.Property(p =&gt; p.Id).HasColumnName("UserId");
              c.Properties(p =&gt; new
              {
                  p.AccessFailedCount,
                  p.Email,
                  p.EmailConfirmed,
                  p.PasswordHash,
                  p.PhoneNumber,
                  p.PhoneNumberConfirmed,
                  p.TwoFactorEnabled,
                  p.SecurityStamp,
                  p.LockoutEnabled,
                  p.LockoutEndDateUtc,
                  p.UserName
              });
          }).HasKey(c =&gt; c.Id);
          modelBuilder.Entity&lt;ApplicationUser&gt;().HasMany(c =&gt; c.Logins).WithOptional().HasForeignKey(c =&gt; c.UserId);
          modelBuilder.Entity&lt;ApplicationUser&gt;().HasMany(c =&gt; c.Claims).WithOptional().HasForeignKey(c =&gt; c.UserId);
          modelBuilder.Entity&lt;ApplicationUser&gt;().HasMany(c =&gt; c.Roles).WithRequired().HasForeignKey(c =&gt; c.UserId);
  
          modelBuilder.Entity&lt;ApplicationUserRole&gt;().Map(c =&gt;
          {
              c.ToTable("UserRole");
              c.Properties(p =&gt; new
              {
                  p.UserId,
                  p.RoleId
              });
          })
          .HasKey(c =&gt; new { c.UserId, c.RoleId });
  
  
          modelBuilder.Entity&lt;ApplicationUserClaim&gt;().Map(c =&gt;
          {
              c.ToTable("UserClaim");
              c.Property(p =&gt; p.Id).HasColumnName("UserClaimId");
              c.Properties(p =&gt; new
              {
                  p.UserId,
                  p.ClaimValue,
                  p.ClaimType
              });
          }).HasKey(c =&gt; c.Id);
      }
  </code></pre>
  
  <p>I am getting an error :
  "The foreign key component 'RoleId' is not a declared property on type 'ApplicationUserRole'. Verify that it has not been explicitly excluded from the model and that it is a valid primitive property."</p>
  
  <p>The ApplicationUserRole is extending from following class:</p>
  
  <pre><code>      //   TKey:
  public class IdentityUserRole&lt;TKey&gt;
  {
      public IdentityUserRole();
  
      // Summary:
      //     RoleId for the role
      public virtual TKey RoleId { get; set; }
      //
      // Summary:
      //     UserId for the user that is in the role
      public virtual TKey UserId { get; set; }
  }
  </code></pre>
  
  <p>Why does I get this error ?</p>
  
  <p>I have read some of SO threads, that state , the extending properties are identified or mapped with Model binder (code first) and stating that to override those properties in derived classes. Even I have done that, the same error is occured. </p>
  
  <p>And the ApplicationUserRole entity mapping has been done to solve many to many relationship between users and roles entities. </p>