I am trying to implement common DDD-based entity using Entity Framework Core. I have 2 separated databases, external and internal, which shares common table models and logic in some places. Ive tried to implement it that way:
public abstract class EmployeeBase
{
public Guid Id {get;}
public string Name {get; protected set;}
public Guid DepartmentId {get; protected set;}
public DeparmentBase {get; protected set;}
public void DomainMethod1() {...}
public void DomainMethod2() {...}
}
public class InternalEmployee : EmployeeBase
{
}
public class ExternalEmployee : EmployeeBase
{
}
public abstract class DepartmentBase
{
public Guid Id {get;}
public string Name {get; protected set;}
public ICollection<EmployeeBase> Employees {get; protected set;}
public void DomainMethod1() {...}
public void DomainMethod2() {...}
}
public class InternalDepartment : DepartmentBase
{
}
public class ExternalDepartment : DepartmentBase
{
}
Is it even possible to to that in entity framework core? I can not find the way to configure it using FluentAPI. Can anyone help? I am also not sure if it is a good idea to implement domain logic in abstract classes with nested properties of abstract type as well. Is there any better alternative? Thank you in advance!ent