I have a problem with connection between 2 entities when there is 2 navigations.
to be specific, I have the following classes:
public class TableA
{
use this Code :
public class TableA
{
public TableA()
{
ListBs = new List();
}
[Key]
public int Id { get; set; }
public int TableB_Id { get; set; }
[InverseProperty("TableA_Mains")]
[ForeignKey("TableB_Id")]
public TableB MainB { get; set; }
[InverseProperty("refA")]
public virtual ICollection ListBs { get; set; }
}
public class TableB
{
[Key]
public int Id { get; set; }
public int TableA_Id { get; set; }
[Foreignkey("TableA_Id")]
[InverseProperty("ListBs")]
public virtual TableA refA { get; set; }
[Required]
public string Text { get; set; }
[InverseProperty("MainB")]
public virtual ICollection TableA_Mains { get; set; }
}