Best way to utilize navigation property in EF core inheritance

125 Views Asked by At

here is my question:

I have an "Admin" class which can inherit from "ServiceUser (abstract)" however i'd rather abstain from doing so. Here's the class diagram:

In "Account" I have to set up the navigation properties. "Admin Account" inherits indirectly from Account. pic below : class diagram

Here's my solution so far but it seems messy.

public abstract class Account<T> where T : ServiceUser
{
    // some fields from the class diagram
    public int OwnerId { get; set; }
    
    public T AccountOwner { get; set; }
    // how to set up this ^ ?
}

What would be the best way to set up this navigation property so that Accounts may contain a reference to the Customer, Seller or Admin?

0

There are 0 best solutions below