尝试添加Override void ParseEntity时,会收到以下错误消息:
严重级代码描述项目文件行抑制状态 错误CS0115' ApplicationUser.ParseEntity(ref ApplicationUser)':找不到合适的方法来覆盖... \ Models \ IdentityModels.cs 47 Active
我正在尝试添加:
public override void ParseEntity(ref ApplicationUser entity)
{
entity.Email = Email;
entity.UserName = Email;
entity.FirstName = FirstName;
entity.LastName = LastName;
entity.UserTypeID = UserTypeID;
entity.ModifiedDate = DateTime.Now;
entity.ModifiedBy = Id;
}
到我的IdentityModel.cs。 ApplicaionUser看起来如下:
public class ApplicationUser : IdentityUser<string, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim>
{
public ApplicationUser()
{
this.Id = Guid.NewGuid().ToString();
// Add any custom User properties/code here
}
[Display(Name = "First Name")]
[Required]
public string FirstName { get; set; }
[Display(Name = "Last Name")]
[Required]
public string LastName { get; set; }
[Display(Name = "Guarantee Limit")]
public Nullable<double> GuaranteeLimit { get; set; }
[Display(Name = "User Type")]
public int UserTypeID { get; set; }
[Display(Name = "Terms And Conditions Version")]
public string TermsAndConditionsVersion { get; set; }
[Display(Name = "Last Terms And Conditions Date")]
public DateTime ? LastTermsAndConditionsDate { get; set; }
[Display(Name = "Last Login Date And Time")]
public DateTime ? LastLoginDateTime { get; set; }
[Display(Name = "Created Date")]
public DateTime CreatedDate { get; set; }
[Display(Name = "Modified Date")]
public DateTime ? ModifiedDate { get; set; }
[Display(Name = "Modified By")]
public string ModifiedBy { get; set; }
/////////////////I want to add the override here/////////////////
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(ApplicationUserManager 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;
}
}
我可以在这里添加覆盖,还是我遗漏了什么?我看了一些帖子并尝试了使用System.Web.Mvc添加的建议,但这没有区别,同样的错误信息。
答案 0 :(得分:1)
您的ApplicationUser 实施 IdentityUser界面。接口无法覆盖。您的ApplicationUser类必须从另一个具有ParseEntity的类继承作为虚拟或抽象方法才能覆盖它。