coreex-aggregate

Creates DDD aggregate roots, child entities, and value objects in a CoreEx Domain layer.

28|8|Updated Feb 21, 2022
One-click install
npx skills add https://github.com/Avanade/CoreEx --skill coreex-aggregate-avanade
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: coreex-aggregate
Source: https://github.com/Avanade/CoreEx/tree/main/.github/skills/coreex-aggregate
Command: npx skills add https://github.com/Avanade/CoreEx --skill coreex-aggregate-avanade

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Designing domain objects in a CoreEx-based .NET solution requires choosing between aggregate roots, child entities, and value objects, then applying the correct CoreEx.DomainDriven patterns (factory methods, PersistenceState, mutation guards). This Skill interviews the developer to pick the right pattern and generates conforming code. ## Core Features & Use Cases - Aggregate Root Creation: Generates Aggregate<TId, TSelf> classes with CreateNew/CreateFrom factory methods, OnCheckCanMutate guards, OnMutate hooks, and integration-event accumulation via AddEvent. - Child Entity & Value Object Patterns: Produces Entity<TId, TSelf> child entities with internal mutation methods and sealed record value objects with invariant-enforcing init accessors, including JSON-column-backed value object guidance. - Unit Test Guidance: Provides aggregate unit-test conventions using WithGenericTester<EntryPoint> and Test.Scoped(...), covering both happy-path mutations and guard-rejection assertions. - Use Case: When adding a new Basket aggregate with child BasketItem entities and an Address value object to a CoreEx solution, this Skill walks you through each object's correct structure, mutation methods, and tests. ## Quick Start Ask the assistant to add a new aggregate root with mutation methods and invariant guards to your CoreEx Domain project.

Frequently Asked Questions about coreex-aggregate

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create an aggregate root in CoreEx?▼

Extend Aggregate<TId, TSelf> from CoreEx.DomainDriven with a private constructor and two factory methods: CreateNew calling .AsNew() and CreateFrom calling .AsNotModified(). Expose read-only properties and mutation methods that go through Modify(...) or Remove(...) so guards and PersistenceState transitions apply.

What is the difference between an aggregate root, entity, and value object in CoreEx?▼

An aggregate root extends Aggregate<TId, TSelf> and is the consistency boundary loaded and saved as a unit. A child entity extends Entity<TId, TSelf> with identity but internal-only mutation methods. A value object is a sealed record with no identity, defined entirely by its values.

When should I skip the Domain layer in CoreEx?▼

Skip the Domain layer for CRUD-oriented entities with no meaningful invariants to enforce at the model level. In that case, let the Application service orchestrate directly against repository interfaces using coreex-contract, coreex-repository, and coreex-app-service instead.

Does CoreEx support domain events with MediatR?▼

No, CoreEx deliberately does not provide in-process domain-event dispatch. Aggregates only support integration events via AddEvent(EventData), which the Application layer forwards through IUnitOfWork.Events for transactional outbox publishing to other systems.

How do I unit test CoreEx aggregates?▼

Create a test class extending WithGenericTester<EntryPoint> and wrap each test in Test.Scoped(...). Construct the aggregate directly via CreateFrom, call its public mutation methods, and assert guard failures as thrown BusinessException instances plus unchanged state.

Why does OnCheckCanMutate throw instead of returning a failed Result?▼

OnCheckCanMutate returns a Result but is invoked internally via .ThrowOnError(), so a failing guard throws the exception carried by the Result, typically a BusinessException. Public mutation methods should still return Result for composability in Application-layer pipelines.