我无法从Identity扩展属性。
这样做的全部原因是使我的员工数据库与应用程序数据库(包括身份信息)集成在一起,并将其用作一个大型数据库。
我尝试遵循此答案,但似乎他们正在使用另一版本的ASP.NET。我正在使用ASP.NET Core,版本:2.0.3
这是我ApplicationUser.cs文件的代码
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; }
}
}
我在出现错误CreateIdentityAsync,并显示以下错误:
'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]
和上的错误DefaultAuthenticationTypes,错误:
The name 'DefaultAuthenticationTypes' does not exist in the current context [src]
使用ASP.NET Core无法做到这一点,还是我做错了什么?
相关分类