Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将Employees导航属性添加到已具有Manager导航属性的ASP.NET Identity ApplicationUser?_C#_Asp.net_Asp.net Mvc_Asp.net Identity - Fatal编程技术网

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; }