类AttributeImage包含 SmallImageID , MediumImageID 和 LargeImageID ,它们与类Image中的 ImageID 相关。我觉得我做错了,我很高兴知道如何做到这一点。
这是课程:
class AttributeImage
{
[Key]
public int AttributeImageID { get; set; }
[Required]
public int AttributeID { get; set; }
[Required]
[ForeignKey("ImageID")]
public int SmallImageID { get; set; }
[Required]
[ForeignKey("ImageID")]
public int MediumImageID { get; set; }
[Required]
[ForeignKey("ImageID")]
public int LargeImageID { get; set; }
public virtual Attribute Attribute { get; set; }
public virtual Image Image { get; set; }
}
public class Image
{
[Key]
public int ImageID { get; set; }
public byte[] Data { get; set; }
[HiddenInput(DisplayValue = false)]
public string Type { get; set; }
public virtual ICollection<AttributeImage> AttributeImages { get; set; }
}
谢谢!