将数据保存在服务器上的中间表上

时间:2017-02-06 07:33:15

标签: c# sql azure

作为项目中的示例,有WorkReason和WorkAreas表。 EFModel包含WorkReason和WorkArea。我们可以将WorkReason和WorkArea添加到SQL中,但我无法在那里添加WorkReasonWorkAreas。我该怎么做? WorkReasonWorkAreas表用于连接WorkReason和WorkAreas。

下面的代码显示WorkReason和WorkAreas位于EFModel中。

public partial class WorkReason
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
    public WorkReason()
    {
        this.Dates = new HashSet<Date>();
        this.WorkAreas = new HashSet<WorkArea>();
        this.WorkTypes = new HashSet<WorkType>();
    }

    public int WorkReasonID { get; set; }
    public int PlannedWorkID { get; set; }
    public int ClientManagerID { get; set; }
    public int ProfesionID { get; set; }
    public string Name { get; set; }
    public int StatusID { get; set; }

    public virtual PlannedWork PlannedWork { get; set; }
    public virtual Profession Profession { get; set; }
    public virtual Status Status { get; set; }
    public virtual User User { get; set; }
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
    public virtual ICollection<Date> Dates { get; set; }
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
    public virtual ICollection<WorkArea> WorkAreas { get; set; }
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
    public virtual ICollection<WorkType> WorkTypes { get; set; }
}

public partial class WorkArea
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
    public WorkArea()
    {
        this.WorkReasons = new HashSet<WorkReason>();
    }

    public int WorkAreaID { get; set; }
    public int JobLocationID { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }

    public virtual JobLocation JobLocation { get; set; }
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
    public virtual ICollection<WorkReason> WorkReasons { get; set; }
}

0 个答案:

没有答案