Entity that has multiple properties referencing same entity

Viewed 21

I have a scenario where an entity needs to connect to another entity multiple times using different relationships.

class Binder
{
    //additional properties//

    Check Check {get; set;}
    List<Check> SubChecks {get; set;}
}

class Check
{
    //additional properties//

    Binder Binder {get;set;}
    List<Binder>? GroupBinders {get;set;}
}

Now naturally EF Core loses its mind as it cannot determine the relationship directions and ownership.

So i attempted to do something in OnModelCreating but i just cannot figure out the right combination for the life of me.

Use case is:

Binder can have multiple checks
But those Checks can have multiple binders

So essentially you end up with a big tree. Top of the tree is always a binder.

0 Answers
Related