I am trying to customize some ASP.NET Identity Core classes which use Generics.
My ApplicationUser class:
public class ApplicationUser : IdentityUser<Guid>//, ApplicationUserClaim, ApplicationRole, ApplicationUserLogin>
{
public ApplicationUser() { }
}
My ApplicationUserStore class:
public class ApplicationUserStore : UserStore<ApplicationUser, ApplicationRole, ApplicationDbContext, Guid>
{
public ApplicationUserStore(ApplicationDbContext ctx, IdentityErrorDescriber describer = null) : base(ctx, describer)
{
}
}
Error message is:
'AspDotNetCoreFullFramework.Identity.ApplicationUser
1[System.Guid]', on
Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore`8[TUser,TRole,TContext,TKey,TUserClaim,TUserRole,TUserLogin,TUserToken]' violates the constraint of type parameter 'TUser'
Now, when I go to the .NET implementation of UserStore (Base class):
public class UserStore<TUser, TRole, TContext, TKey> : UserStore<TUser, TRole, TContext, TKey, IdentityUserClaim<TKey>, IdentityUserRole<TKey>, IdentityUserLogin<TKey>, IdentityUserToken<TKey>>
where TUser : IdentityUser<TKey>
... where TKey : IEquatable<TKey> {
I can see that ApplicationUser inherits from IdentityUser<GUID>. This constraint is fulfilled. TKey is GUID which implements IEquatable<GUID>. This constraint is also fulfilled.
So what is the problem?