I have these class in my code :
public class Parent
{
[Key]
public int ParentID { get; set; }
public string ParentName { get; set; }
public virtual ICollection<Child> Childs { get; set; }
}
public class Child
{
[Key]
public int ChildID { get; set; }
public string ChildName { get; set; }
public int ParentID { get; set; }
[ForeignKey("ParentID")]
public virtual Parent Parent { get; set; }
}
Parent
have one-to-many relationship with Child
and Child
have Parent
property. Is this going to cause me trouble in the future? Because I just got Self referencing loop detected
exception when trying to convert this class into JObject
with Newtonsoft. Am I suppose to remove Parent
property from Child
so it doesn't cause self referencing?