问题描述
我有以下代码,其中包含基本的一对多设置。遵循 entityframeworktutorial.net 中的指南,我试图了解放置导航属性的位置。我采用了约定 4,如教程中所述,使用不可为空的键。
public class VendorImage
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int VendorImageId { get; set; }
[Required,MaxLength(50)]
public string ImageUrl { get; set; }
public int VendorId { get; set; }
public Vendor Vendor { get; set; }
}
public class Vendor
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int VendorId { get; set; }
[Required,MaxLength(50)]
public string Name { get; set; }
public ICollection<VendorImage> VendorImages { get; set; }
}
使用邮递员进行测试时,我收到错误消息“检测到不支持的可能对象循环。”
然后我从 Vendor
中删除了 VendorImage
属性,它工作正常。
对此有解释吗?我想了解一下。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)