我有一个实体需要包含自己的相关实体:
public class Period
{
public int ID {get; set;}
public DateTime StartDate {get; set;}
public DateTime EndDate {get; set;}
public Period PriorPeriod {get; set;}
}
如何仅使用POCO实现此目的,还是需要Fluent API映射?
答案 0 :(得分:0)
public class Period
{
public int ID { get; set; }
public int? PriorPeriodID { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
[ForeignKey("PriorPeriodID")]
public Period PriorPeriod { get; set; }
}