How to have two self-references in an entity class
问题 I have a Foo that can have two optional references to itself: ParentId and RootId . public class Foo { [Key] public int FooId { get; set; } public int? ParentId { get; set; } [ForeignKey(nameof(ParentId))] public virtual Foo Parent { get; set; } public int? RootId { get; set; } [ForeignKey(nameof(RootId))] public virtual Foo RootFoo { get; set; } // ... } Having one works fine, but when I introduce the second self-reference I get error: Unable to determine the principal end of an association