I'm developing a Web Api 2.2 application with .NET Framework 4.5.1 and Asp.Net Identity 2.1.0.
I'm not sure what I'm doing, but I want to merge my database with ASP.NET Identity database and I have done this:
My own dbContext
.
public class EFDbContext : IdentityDbContext, IUnitOfWork
My own User
class.
public class User :
IdentityUser<long,
IdentityUserLogin<long>,
IdentityUserRole<long>,
IdentityUserClaim<long>
>
But when I do this:
UserManager<User> _userManager;
I get this error:
The type Data.Models.User
cannot be used as parameter of type TUser
. There isn't any explicit conversion from Data.Models.User
to Microsoft.AspNet.Identity.IUser<string>
.
I'm doing this because I want to have IdentityUser.Id
as long
instead of string
.
How can I fix this error?
UPDATE
After updating UserManager with:
UserManager<User, long> _userManager;
I get the three errors here:
EFDbContext_ctx = context as EFDbContext;
_userManager = new UserManager<User, long>(new UserStore<User>(_ctx));
- The best match of method overload for 'Microsoft.AspNet.Identity.UserManager.UserManager (Microsoft.AspNet.Identity.IUserStore )' has some invalid arguments-
- The type 'Data.Models.User' cannot be used as parameter of type 'TUser' type or generic method 'Microsoft.AspNet.Identity.EntityFramework.UserStore '. There is no conversion from implicit reference from 'Data.Models.User' to 'Microsoft.AspNet.Identity.EntityFramework.IdentityUser'.
- Argument 1: cannot be converted from 'Microsoft.AspNet.Identity.EntityFramework.UserStore' to 'Microsoft.AspNet.Identity.IUserStore'
How can I fix this new error?
Use the other UserManager
UserManager<User, long> _userManager;
You are using this UserManager which:
Represents the user manager for users where the primary key for the user is of type string.