title: ASP.NET Identity 2.1 change PK to int error
body: <p>I have changed the PK as described in <a href="http://www.asp.net/identity/overview/extensibility/change-primary-key-for-users-in-aspnet-identity" rel="nofollow">http://www.asp.net/identity/overview/extensibility/change-primary-key-for-users-in-aspnet-identity</a>, however after I try to login, i get the following error. The login part is successful because "this" contains all the approperate data, however creating identity seems to fail</p>
  
  <p><strong>The specified cast from a materialized 'System.String' type to the 'System.Int32' type is not valid.</strong> </p>
  
  <p>at the line </p>
  
  <pre><code>var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
  </code></pre>
  
  <p>of the method</p>
  
  <pre><code> public class ApplicationUser : IdentityUser&lt;int, CustomUserLogin, CustomUserRole, CustomUserClaim&gt;
  {
      public async Task&lt;ClaimsIdentity&gt; GenerateUserIdentityAsync(UserManager&lt;ApplicationUser, int&gt; manager)
      {
          // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
          var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
          // Add custom user claims here
          return userIdentity;
      }
      public string FirstName { get; set; }
      public string LastName { get; set; }
  
  }
  </code></pre>