I'm having trouble extending properties from Identity.
The whole reason for this is to have my employee database integrated with the application database (which includes the identity stuff) and use it as one big database.
I tried following this answer, but seems like they are using another version of ASP.NET. I'm using ASP.NET Core, Version: 2.0.3
Here is the code for my ApplicationUser.cs
file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
namespace src.Models
{
public class ApplicationUser : IdentityUser
{
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager) {
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
userIdentity.AddClaim(new Claim("FirstName", this.FirstName.ToString()));
userIdentity.AddClaim(new Claim("LastName", this.LastName.ToString()));
userIdentity.AddClaim(new Claim("JobTitle", this.JobTitle.ToString()));
userIdentity.AddClaim(new Claim("Status", this.Status.ToString()));
return userIdentity;
}
string FirstName { get; set; }
string LastName { get; set; }
string JobTitle { get; set; }
string Status { get; set; }
int Age { get; set; }
}
}
I'm getting an error on CreateIdentityAsync
, with the error:
'UserManager<ApplicationUser>' does not contain a definition for 'CreateIdentityAsync'
and no extension method 'CreateIdentityAsync' accepting a first argument of type
'UserManager<ApplicationUser>' could be found (are you missing a using directive
or an assembly reference?) [src]
and an error on DefaultAuthenticationTypes
, the error:
The name 'DefaultAuthenticationTypes' does not exist in the current context [src]
Is this not possible with ASP.NET Core, or that I'm doing something wrong?