我在ApplicationUser.cs中添加了属性(之前我已经做过),一切都爆炸了。此类扩展了IdentityUser。当我注释掉属性时,一切似乎都能正常工作。我做错了什么?
ApplicationUser.cs
public class ApplicationUser : IdentityUser
{
public string LGID { get; } = "";
public string CoIDs { get; } = "";
public string LGIDSuperUserName { get; set; } = "unknown"; //new
public bool IsSuperUser { get; set; } = false; //new
public ApplicationUser() { }
public ApplicationUser(ClaimsIdentity identity)
{
IEnumerable<Claim> claims = identity.Claims;
foreach (Claim c in claims)
{
if (c.Type == "LGID")
LGID = c.Value;
if (c.Type == "CoIDs")
CoIDs = c.Value;
if (c.Type == "LGIDSuperUser")
LGIDSuperUserName = c.Value;
if (c.Type == "IsSuperUser")
IsSuperUser = c.Value.ToLower()=="yes";
}
}
}
如果需要,请提供更多信息。不确定这里有什么相关
当我登录我的网站时,我首先收到一条错误消息,表明我需要迁移数据库。在NuGet包管理器中,我跑了:
Add-Migration ApplicationDbContext
Update-Database
现在我尝试登录时出现错误消息:
Invalid column name 'IsSuperUser'.
var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, lockoutOnFailure: false);