Skip to main content
The Domain Modeler provides a visual design surface for modeling your application’s domain layer using UML-style class diagrams. It enables you to define entities, value objects, aggregates, and their relationships following Domain-Driven Design (DDD) principles.

Overview

The Domain Modeler is based on the Intent.Modelers.Domain module, which provides:
  • UML class diagram-based visual modeling
  • Support for entities, value objects, and data contracts
  • Rich relationship modeling (associations, generalizations)
  • Attribute and operation definitions
  • Domain-specific stereotypes and metadata

Designer Configuration

The Domain designer is configured with:
  • Designer ID: 6ab29b31-27af-4f56-a67c-986d82097d63
  • Designer Name: Domain
  • Order: 10 (appears after Services in the designer list)
  • Type Systems: Common Types, Domain Types

Core Elements

Class (Entity)

Classes represent domain entities - objects with identity and lifecycle. Properties:
  • Name: The entity name (e.g., Customer, Order)
  • Abstract: Whether the class is abstract
  • Attributes: Properties/fields on the entity
  • Operations: Methods and behaviors
  • Constructors: Constructor definitions
Example Usage:
var entity = element.AsClassModel();
var name = entity.Name;
var attributes = entity.Attributes;
var operations = entity.Operations;

Attribute

Attributes represent properties or fields on classes. Properties:
  • Name: Attribute name
  • Type: Data type (primitives, enums, or other classes)
  • Default Value: Optional default value
  • Is Nullable: Whether the attribute can be null
  • Is Collection: Whether it’s a collection type
Example Usage:
var attribute = entity.Attributes.First();
var typeName = attribute.TypeReference.Element.Name;
var isNullable = attribute.TypeReference.IsNullable;

Association

Associations represent relationships between classes. Association Types:
  • Aggregation: Whole-part relationship (e.g., Order has OrderItems)
  • Composition: Strong ownership (part cannot exist without whole)
  • Association: General relationship
Properties:
  • Source End: The source class and multiplicity
  • Target End: The target class and multiplicity
  • Navigability: Whether the relationship is navigable in one or both directions
Multiplicity Options:
  • 0..1 - Zero or one
  • 1 - Exactly one
  • 0..* - Zero or many
  • 1..* - One or many
Example Usage:
var associations = entity.AssociatedClasses;
foreach (var assoc in associations)
{
    var targetClass = assoc.Class;
    var isCollection = assoc.IsCollection;
    var isNullable = assoc.IsNullable;
}

Generalization (Inheritance)

Generalizations represent inheritance relationships.
var baseClass = entity.ParentClass;
var derivedClasses = entity.ChildClasses;

Data Contract

Data contracts represent value objects or simple data transfer structures without identity.

Operation

Operations define methods and behaviors on domain entities. Properties:
  • Name: Operation name
  • Return Type: The type returned by the operation
  • Parameters: Input parameters
  • Is Static: Whether it’s a static method
  • Is Abstract: Whether it’s an abstract method

Folder

Folders organize domain elements hierarchically, typically mapping to namespaces.

Domain Modeling Patterns

Entities

Entities are objects with unique identity that persist over time. Characteristics:
  • Have a unique identifier (typically an Id attribute)
  • Mutable state
  • Lifecycle managed by aggregates
Best Practices:
  • Use stereotypes to mark root entities as Aggregates
  • Define clear boundaries for each aggregate
  • Model entity relationships using associations

Value Objects

Value objects are immutable objects defined by their attributes rather than identity. Characteristics:
  • No unique identifier
  • Immutable
  • Equality based on attribute values
Modeling Approach:
  • Use Data Contract elements for value objects
  • Add a stereotype to indicate value object semantics
  • Avoid associations to entities (use composition instead)

Aggregates

Aggregates are clusters of entities and value objects with defined consistency boundaries. Modeling Approach:
  • Mark the root entity with an Aggregate stereotype
  • Model aggregate members using composition associations
  • Define operations on the aggregate root

Metadata API

Accessing Domain Models

using Intent.Modelers.Domain.Api;

var domainPackage = model.GetDomainPackageModel();
var classes = domainPackage.Classes;

Working with Classes

var entity = element.AsClassModel();

// Basic properties
var name = entity.Name;
var isAbstract = entity.IsAbstract;

// Attributes
foreach (var attr in entity.Attributes)
{
    var attrName = attr.Name;
    var attrType = attr.TypeReference.Element.Name;
}

// Associations
foreach (var assoc in entity.AssociatedClasses)
{
    var relatedClass = assoc.Class.Name;
    var isCollection = assoc.IsCollection;
}

Stereotypes

if (entity.HasStereotype("Aggregate"))
{
    // Handle aggregate root entity
}

Designer Settings

The Domain Modeler provides application-level settings:

Naming Conventions

Attribute Naming Convention
  • Options: Manual, Pascal Case, Camel Case
  • Default: Manual
  • Controls automatic naming when creating/renaming attributes
Entity Naming Convention
  • Options: Manual, Pascal Case, Camel Case
  • Default: Manual
  • Controls automatic naming when creating/renaming entities
Operation Naming Convention
  • Options: Manual, Pascal Case, Camel Case
  • Default: Manual
  • Controls automatic naming when creating/renaming operations

Common Modeling Scenarios

Modeling an Aggregate

  1. Create a root entity (e.g., Order)
  2. Add the Aggregate stereotype to mark it as an aggregate root
  3. Create child entities (e.g., OrderItem)
  4. Create composition associations from root to children
  5. Add attributes and operations to the root entity

Modeling Inheritance

  1. Create a base class (e.g., Person)
  2. Create derived classes (e.g., Customer, Employee)
  3. Draw generalization arrows from derived to base class
  4. Add shared attributes to the base class
  5. Add specific attributes to derived classes

Modeling Relationships

One-to-Many:
  1. Create two entities (e.g., Customer and Order)
  2. Draw an association from Customer to Order
  3. Set target multiplicity to 0..* or 1..*
Many-to-Many:
  1. Create two entities (e.g., Student and Course)
  2. Create a junction entity (e.g., Enrollment)
  3. Create two one-to-many relationships

Integration with Modules

The Domain Modeler integrates with:
  • Entity Framework Templates: Generate EF Core entities and DbContext
  • Repository Templates: Generate repository patterns
  • Domain Events: Model and generate domain event infrastructure
  • Validation: Add validation logic through stereotypes
  • Mapping: Generate mapping configurations between domain and DTOs

Best Practices

  1. Start with Aggregates: Identify aggregate boundaries before detailed modeling
  2. Use Folders: Organize models into logical folders matching bounded contexts
  3. Leverage Stereotypes: Use stereotypes to add framework-specific metadata
  4. Model Behavior: Don’t just model data - add operations that represent domain logic
  5. Keep Diagrams Focused: Create multiple diagrams for different views of the domain
  6. Use Consistent Naming: Configure naming conventions for consistency
  7. Document Relationships: Add comments to associations explaining the business meaning

Example Domain Model

A typical e-commerce domain model might include:
Aggregates:
- Order (root)
  - OrderItem (composition)
  - Address (value object)
  
- Customer (root)
  - CustomerAddress (composition)

Entities:
- Product
- Category

Value Objects:
- Money
- Address
- Email

Relationships:
- Customer → Order (one-to-many)
- Order → Product (many-to-many via OrderItem)
- Product → Category (many-to-one)