I would like to map something like this:
public class FooPair
{
public int Id { get; set; }
public Foo Foo1 { get; set; }
public Foo Foo2 { get; set; }
}
public class Foo
{
public int Id { get; set; }
public FooPair Parent { get; set; }
}
And my DbContext:
public class FooContext : DbContext
{
public DbSet<Foo> Foos { get; set; }
public DbSet<FooPair> Pairs { get; set; }
}
EF is complaining it's unable to determine the relationship represented by the Parent
navigation property.
The only solution I could think of, is to create two new inherited classes fom Foo
, then EF will map them to their own tables and I get two 1-to-1 relations, but this doesn't feel right.
What would be the correct way of modeling such situation?