При попытке добавить на Override ничтожной ParseEntity и получить следующее сообщение об ошибке:Можно ли переопределить ApplicationUser для Identity ASP.NET?
Тяжесть Код Описание проекта Строка файла Подавление State CS0115 Error «ApplicationUser.ParseEntity (исх ApplicationUser)»: не подходящий способ найти переопределить .. . \ Models \ IdentityModels.cs 47 Активные
Я пытаюсь добавить:
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, но это не имеет значения, такое же сообщение об ошибке.
Не существует метода 'ParseEntity' в любом месте. Удалите 'override', и вы будете в порядке, если хотите его использовать. – trailmax