【发布时间】:2018-11-08 06:49:31
【问题描述】:
我正在使用用户身份制作 ASP.NET MVC 项目。我的 User 类现在继承自 IdentityUser:
[Table("Users")]
public class User : IdentityUser
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Patronymic { get; set; } // Отчество
public string Avatar { get; set; }
public DateTime? DateOfBirth { get; set; } // Дата рождения
public DateTime? RegisterDate { get; set; } // Actualy it is a dateTime :)
public bool? Sex { get; set; }
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<User> 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;
}
}
然后我创建了 Doctor 类,它继承自它:
[Table("Doctors")]
public class Doctor : User
{
[Key]
public int DoctorId { get; set; }
public string CurriculumVitae { get; set; }
}
如您所见,我添加了自定义索引字段 DoctorId。 但 UserManager 无法创建实体 所以问题是如何添加 CUSTOM INT ID 索引?
【问题讨论】:
-
@JohnB,最好不要更改基表
标签: c# sql-server asp.net-mvc entity-framework