I have a question on modelling an Entity\Aggregate root in DDD. I am refactoring a project that uses Entity Framework and business logic as services, the services contain lots of logic which I believe should be in entities in DDD.
public class Contractor
{
public int Id {get;set;}
public DateTime ContractStartDate {get;set;}
public DateTime ContractEnddate {get;set;}
public string PhoneNumber {get;set;}
public Address Address {get;set;}
/*Bunch of other properties */
public ICollection<Site> ContractorSites {get;set;}
}
public class Site
{
public int Id {get;set;}
/*Bunch of other properties */
}
Now I am trying to model the Contractor as an Entity. The problem I am facing is with the ContractorSites property. A contractor can have one or more sites associated to him.
Now when I am modelling a contractor as an Entity, should I include this property? If I include this does this mean that every time I want to fetch a contractor's details from the database and create this entity, I will have to fetch the related sites as well?
My question boils down to "should we include all relationships in the domain entity?"