我有一种情况,我有课JobDescription
和 Image
. 我想建立一到零或多的关系。如果 JobDescription 存在,它可能有图像集合或根本没有任何图像。Image 和 ImageSection 也是如此。我的课程做得对吗?
public class JobDescription
{
public int JobDescriptionID { get; set; }
// Other attributes and navigations
public int? ImageID { get; set; }
[ForeignKey("ImageID")]
public virtual List<Image> Image { get; set; }
}
public class Image
{
public int ImageID { get; set; }
public string ImageName { get; set; }
public int? ImageSectionID { get; set; }
[ForeignKey("ImageSectionID")]
public virtual ImageSection ImageSection { get; set; }
}