C# 如何将Employees导航属性添加到已具有Manager导航属性的ASP.NET Identity ApplicationUser?
我目前拥有C# 如何将Employees导航属性添加到已具有Manager导航属性的ASP.NET Identity ApplicationUser?,c#,asp.net,asp.net-mvc,asp.net-identity,C#,Asp.net,Asp.net Mvc,Asp.net Identity,我目前拥有ApplicationUser实体,该实体从身份框架扩展了IdentityUser [Table("User")] public class ApplicationUser : IdentityUser<string, IdentityUserLogin, ApplicationUserRole, IdentityUserClaim> { [Column("CreatedDate"), DataType("datetime2")] public DateTi
ApplicationUser
实体,该实体从身份框架扩展了IdentityUser
[Table("User")]
public class ApplicationUser : IdentityUser<string, IdentityUserLogin, ApplicationUserRole, IdentityUserClaim>
{
[Column("CreatedDate"), DataType("datetime2")]
public DateTime? CreatedOn { get; set; }
[Column("CreatedBy")]
public string CreatedBy { get; set; }
[Column("ModifiedDate"), DataType("datetime2")]
public DateTime? ModifiedOn { get; set; }
[Column("ModifiedBy")]
public string ModifiedBy { get; set; }
[Column("LastLoginDate"), DataType("datetime2")]
public DateTime? LastLoginOn { get; set; }
[Column("TimeZoneID"), ForeignKey("TimeZone")]
public string TimeZoneId { get; set; }
[Column("RegionID"), ForeignKey("Region")]
public string RegionId { get; set; }
[Column("ManagerID"), ForeignKey("Manager")]
public string ManagerId { get; set; }
public virtual TimeZone TimeZone { get; set; }
public virtual Region Region { get; set; }
public virtual ApplicationUser Manager { get; set; }
public virtual ICollection<Appointment> Appointments { get; set; }
public virtual ICollection<OnCallGroup> OnCallGroups { get; set; }
public ApplicationUser()
{
Id = Guid.NewGuid().ToString();
Appointments = new HashSet<Appointment>();
OnCallGroups = new HashSet<OnCallGroup>();
}
public ApplicationUser(string userName)
: this(userName, DateTime.UtcNow)
{
}
public ApplicationUser(string userName, DateTime createdOn)
: this()
{
UserName = userName;
CreatedOn = createdOn;
Email = userName;
EmailConfirmed = true;
}
private ClaimsIdentity GenerateUserIdentity(ApplicationUserManager manager)
{
var userIdentity = manager.CreateIdentity(this, DefaultAuthenticationTypes.ApplicationCookie);
return userIdentity;
}
public Task<ClaimsIdentity> GenerateUserIdentityAsync(ApplicationUserManager manager)
{
return Task.FromResult(GenerateUserIdentity(manager));
}
}
我想添加另一个导航属性,以便容纳属于某些用户的技术人员或员工(例如管理角色),这是一个好主意吗?我怎样才能继续
仅添加以下行即可添加另一个导航属性:
public virtual ICollection<ApplicationUser> Employees { get; set; }
公共虚拟ICollection雇员{get;set;}
你试过了吗?你试过了吗?
public virtual ICollection<ApplicationUser> Employees { get; set; }