I'm currently working with a website which is being developed in ASP.NET and C#. I'm using EF6 and need to change the default tables to my own custom tables. I have managed to do that with a problem. In my custom table the UserId
is an int
rather than default nvarchar(128)
. I am following this demo but I keep getting an error at the first line.
public class ApplicationUser : IdentityUser<int, CustomLogin>
{
}
The error is: " The non-generic type Microsoft.AspNet.Identity.EntityFramework.IdentityUser " cannot be used with type arguments.
I did some research and came across this post . I have updated all the core libraries but the error still exists. Has anyone else faced this problem before or am I the lucky one? Thanks in advance for your help
There are two IdentityUser classes that come with ASP.NET. One is declared as:
public class IdentityUser : IdentityUser<string,
IdentityUserLogin,
IdentityUserRole,
IdentityUserClaim>, IUser
and the other is:
public class IdentityUser<TKey, TLogin, TRole, TClaim> : IUser<TKey>
where TLogin : IdentityUserLogin<TKey>
where TRole : IdentityUserRole<TKey>
where TClaim : IdentityUserClaim<TKey>
You will be declaring a subtype of the generically-typed class and will need all four generic types in the declaration. And you'll also need classes that inherit IdentityUserRole<int>
, IdentityUserClaim<int>
, along with your CustomLogin
class, which I assume is a derivative of IdentityUserLogin<int>
.
Folling your naming convention, you should declare your class as
public class ApplicationUser : IdentityUser<int, CustomLogin, CustomRole, CustomClaim>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.