I have the following code with a basic one-to-many setup. Following the guidelines from entityframeworktutorial.net I'm trying to understand where to place navigation properties. I went with convention 4 as stated in the tutorial with non-nullable key.
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; }
}
Testing it with postman, I get the error "A possible object cycle was detected which is not supported."
I then remove the Vendor property from VendorImage, and it works fine.
Is there an explanation for this? I would like to understand.