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
{
public TableA()
{
ListBs = new List<TableB>();
}
[Key]
public int Id { get; set; }
public TableB MainB { get; set; }
public virtual ICollection<TableB> ListBs { get; set; }
}
public class TableB
{
[Key]
public int Id { get; set; }
public virtual TableA refA { get; set; }
[Required]
public string Text { get; set; }
}
The scenario of this particular classes reflects the following: TableA has a list of TableB objects and also has 1 main TableB object(that is of course in the list too). Also a TableB object may not actualy have a reference to TableA
the fetching works. but when I try to insert new items I get the following exception:
Unable to determine a valid ordering for dependent operations. Dependencies may exist due to foreign key constraints, model requirements, or store-generated values.
Any idea where I got anything wrong?