Reputation: 1199
I am trying to add identity to my MVC project. I want to use an int
as my key instead of a string
. I am getting this error when I try the following:
public partial class AppUser : Microsoft.AspNet.Identity.EntityFramework.IdentityUser<int>
{
}
Is there a library I need to do this or is there a parameter I am missing? Do I need to add IdentityDbContext
to my DbContext
, even if I have already ran scripts to add all the identity tables?
If I remove the <int>
I do not get the error.
Upvotes: 3
Views: 2943
Reputation: 2119
The EntityFramework
provides a default implementation of the IdentityUser
that uses string as key type, but also a generic class where you can customize the types of several properties of the IdentityUser
. To use the generic type, you need to provide all type parameters, not just the one for the primary key as in your example, e.g.:
public partial class AppUser : Microsoft.AspNet.Identity.EntityFramework.IdentityUser<int, IdentityUserLogin<int>, IdentityUserRole<int>, IdentityUserClaim<int>>
{
}
Upvotes: 3