EF 实体关系

  1. 基于共享主键的一对一:

    this.HasRequired(t => t.TRDConInfo)
    .WithOptional(t => t.TRDFoundationProjCheck);

  2. 一对多

    this.HasRequired(t => t.ComponentBelong)
    .WithMany(t => t.TRDConInfos)
    .HasForeignKey(d => d.ComponentBelongID);

  3. 多对多

    this.HasMany(t => t.Contract)
    .WithMany(t => t.DesignChangeAudit)
    .Map(m => {
    m.ToTable("T_Change_DesignAudit_Contract");
    m.MapLeftKey("DesignChangeAuditID");
    m.MapRightKey("ContractID");
    });

posted @ 2015-04-02 19:47  平常心队长  阅读(258)  评论(0编辑  收藏  举报