Skip to main content

Employee Aggregate Storage

Summary

The Employee root uses a GUID primary identifier and integer tenant identifier. Employment is an EF-owned value stored with the root. Profile collections, notes, document references, and timeline entries are separate child objects linked to the root by required foreign keys.

Audience

  • Backend developers and QA engineers
  • Solution architects reviewing aggregate boundaries

Aggregate model

The dashed-in-concept organization and manager relationships are stored as nullable GUID references but are not configured as EF foreign keys. Application validators establish existence, activity, department/designation compatibility, and self-manager rules where the reviewed command path uses them.

Root storage

ConceptConfirmed storage behaviorSource
IdentityGUID root identifier plus tenant identifierDomain/Employees/Employee.cs
Employee codeNormalized value; database uniqueness scoped by tenantEmployeeDbContext.cs
Name/contactRoot scalar values with configured length limitssame
StatusEnum persisted as a bounded string; termination controls active statesame
EmploymentType, work location, joining, confirmation, and birth dates stored inlinesame
OrganizationNullable department, designation, and manager GUID referencessame
Personal profileAddress and government-identifier concepts stored on the rootsame
Lifecycle timestampsCreation and update timestamps on the rootDomain/Employees/Employee.cs

Child storage

All eight child types have their own GUID identifier, Employee identifier, and tenant identifier. EF configures a required Employee foreign key with cascade delete for education, experience, emergency contacts, skills, bank accounts, document references, notes, and timeline entries. Aggregate replacement methods stamp Employee and tenant identity onto new children.

Lifecycle implications

The implemented Employee deletion method is a soft-delete/termination transition. No current direct Employee delete endpoint was documented in Epic 5.3. Physical deletion behavior is nevertheless configured at the database relationship level: if a root row is physically removed by an approved future path, its child rows cascade. Such a physical deletion workflow is Not implemented in the reviewed public API.

Source References

  • microservices/src/employee-service/Domain/Employees/Employee.cs
  • microservices/src/employee-service/Domain/Common/ValueObjects.cs
  • microservices/src/employee-service/Infrastructure/EmployeeDbContext.cs
  • microservices/src/employee-service/Infrastructure/Migrations/20260701173627_InitialEmployeeSchema.cs
  • microservices/src/employee-service/Infrastructure/Migrations/EmployeeDbContextModelSnapshot.cs

See Also

Keywords

  • Aggregate root
  • Owned employment value
  • Employee child storage

Revision Information

  • Status: Draft
  • Last reviewed: 2026-07-15
  • Review cycle: Quarterly