访问多个虚拟财产实体框架

时间:2015-12-20 12:20:03

标签: .net entity-framework

我想从Person实体访问多个虚拟实体。我想实现以下

 public int ClientId { get; set; }
 public virtual Person Client { get; set; }
 public int PartnerId { get; set; }
 public virtual Person Partner { get; set; }

如果有人知道如何使用ForiegnKey属性来定义它,请告诉我吗?

1 个答案:

答案 0 :(得分:0)

像这样:

 [ForeignKey("Client")]
 public int ClientId { get; set; }
 public virtual Person Client { get; set; }
 [ForeignKey("Partner")]
 public int PartnerId { get; set; }
 public virtual Person Partner { get; set; }