MikeT
MikeT

Reputation: 2663

Visual Studio 2015 Moving AspNet.Identity into class library

I've moved AspNet.Identity into a class library many times in VS 2013, but in VS 2015, the compiler complains about the manager parameter throwing this exception

The type 'MyNamespace.ApplicationUser' cannot be used as type parameter 'TUser' in the generic type or method 'UserManager'. There is no implicit reference conversion from 'MyNamespace.ApplicationUser' to 'Microsoft.AspNet.Identity.IUser

in this code:

public class ApplicationUser
{
    public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
    {
        // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
        var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
        // Add custom user claims here
        return userIdentity;
    }
}

All my references and using statements are the same.

What's going on?

Upvotes: 0

Views: 96

Answers (1)

Lewis Taylor
Lewis Taylor

Reputation: 728

I think you have to make your ApplicationUser inherit from IdentityUser.

Upvotes: 2

Related Questions