In Domain-Driven Design, the domain model should be completely unbeknownst of any data persistent specifics.
Let's say that an Employee
belongs to a Department
. The domain entities could look like this:
public Employee
{
public string EmployeeId { get; set; }
public string FirstName { get; set; }
public string LastName{ get; set; }
public Department Department { get; set; }
public int DepartmentId { get; set; }
}
public Department
{
public string DepartmentId { get; set; }
public string Name{ get; set; }
}
Is Employee.DepartmentId
really relevant in the domain model or is that an infrastructure storage detail?
Surely Employee.Department
is the relationship that matters at this level?
In my case, these entities will be stored in a SQL database and the data will be retrieved by Entity Framework, so an Employee.DepartmentId
column will exist in the database.