One-to-one relation + on-to-many relation using same entity

c# entity-framework-core

Popular Answer

With the help of the Entity Framework Fluent API, I was able to resolve my problem as follows:

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    base.OnModelCreating(modelBuilder);

    modelBuilder.Entity<ContactPerson>(e =>
        e.HasOne(r => r.Customer).WithMany(c => c.ContactPersons)
    );
}
0
3/7/2018 7:24:25 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow