Inherit from IdentityUser I get an error on UserManager

asp.net asp.net-identity c# entity-framework

Question

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));
  1. The best match of method overload for 'Microsoft.AspNet.Identity.UserManager.UserManager (Microsoft.AspNet.Identity.IUserStore )' has some invalid arguments-
  2. 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'.
  3. Argument 1: cannot be converted from 'Microsoft.AspNet.Identity.EntityFramework.UserStore' to 'Microsoft.AspNet.Identity.IUserStore'

How can I fix this new error?

1
5
8/14/2017 12:26:45 PM

Popular Answer

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.

5
11/14/2014 4:46:30 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow