Creating a migration for the following entity:
public class Person
{
public long Id { get; set; }
public string Name { get; set; }
public long? MotherId { get; set; }
[ForeignKey(nameof(MotherId))]
public Person Mother { get; set; }
public long? FatherId { get; set; }
[ForeignKey(nameof(FatherId))]
public Person Father { get; set; }
public long? StephMotherId { get; set; }
[ForeignKey(nameof(StephMotherId))]
public Person StepMother { get; set; }
}
create a migration for the person entity.
This isn't working on 3.1.6 either.
EF Core version: 5.0.0-preview.7
Database provider: sqlserver
Target framework: .NET Core 3.1)
Operating system: windows 10 vs 2019. -16.6.5
You need to configure the relationship manually using Fluent API or InversePropertyAttribute. See our documentation for more details.
Note to triage: When ForeignKeyAttribute is specified on both navigations we split the relationship into two, therefore there are no ambiguous candidates in this scenario, so we don't need to throw.
@AndriySvyryd It is working for two self-referencing foreign keys but adding a third breaks it.