JD.Domain Suite

License: MIT .NET Version Test Status

JD.Domain is a production-ready, opt-in domain modeling, rules, and configuration suite for .NET that enables seamless interoperability with Entity Framework Core while supporting two-way generation between EF Core models, domain rules, and rich domain types.


Get Started

Choose your workflow to get started in 5 minutes:

Code-First

Define your domain using the fluent DSL

Code-First Tutorial →

Database-First

Add rules to existing EF Core entities

Database-First Tutorial →

Hybrid

Mix and match with version management

Hybrid Tutorial →

Quick Start Guide | Installation | API Reference


Key Features

Opt-In Domain Rules

Attach business rules to any anemic model (generated or handwritten) with zero required base interfaces. Your existing code stays clean.

Two-Way Generation

Generate EF Core configurations from JD.Domain rules, or generate domain models from EF Core - true bidirectional support.

Rich Domain Models

Generate runtime-safe domain types with automatic invariant enforcement and immutable construction patterns.

Framework Integration

Seamless integration with:

  • Entity Framework Core - ModelBuilder extensions and configuration
  • ASP.NET Core - Middleware and endpoint filters
  • FluentValidation - Automatic validator generation

Version Management

Track domain evolution with snapshots, compare versions, detect breaking changes, and generate migration plans.

Developer Tools

CLI tools for CI/CD integration, source generators for productivity, and T4 template support for legacy codebases.


Example: Code-First Workflow

using JD.Domain.Modeling;
using JD.Domain.Rules;
using JD.Domain.Runtime;

// Define domain model
var domain = Domain.Create("ECommerce")
    .Entity<Customer>()
    .Entity<Order>()
    .Build();

// Define business rules
var customerRules = new RuleSetBuilder<Customer>("Default")
    .Invariant("Customer.Name.Required", c => !string.IsNullOrWhiteSpace(c.Name))
    .WithMessage("Customer name cannot be empty")
    .BuildCompiled();

// Validate at runtime
var result = customerRules.Evaluate(customer);

if (!result.IsValid)
{
    foreach (var error in result.Errors)
    {
        Console.WriteLine(error.Message);
    }
}

See full tutorial →


Architecture

The suite is organized into 15 modular packages that you can mix and match:

Category Packages
Core Abstractions, Modeling, Configuration, Rules, Runtime, Validation
Integration AspNetCore, EFCore
Generators Generators.Core, DomainModel.Generator, FluentValidation.Generator
Tooling Snapshot, Diff, Cli, T4.Shims

View package comparison →


Design Principles

  • Opt-in everything - No required base classes or interfaces
  • Single source of truth - Define once, generate everywhere
  • Deterministic outputs - Stable, predictable code generation
  • Modular - Use only what you need
  • Extensible - Add custom primitives and hooks

Learn more about our design philosophy →


Sample Applications

Explore working examples demonstrating different workflows:

Sample applications guide →


Documentation

Getting Started

Tutorials

Concepts

Reference

View all documentation →


Current Status

v1.0.0 Release Candidate - All core functionality complete

  • ✅ 15 packages fully implemented
  • ✅ 371 tests passing
  • ✅ Complete API documentation
  • ✅ Production-ready samples

View changelog → | View roadmap →


Installation

# Core packages
dotnet add package JD.Domain.Abstractions
dotnet add package JD.Domain.Modeling
dotnet add package JD.Domain.Rules
dotnet add package JD.Domain.Runtime

# EF Core integration
dotnet add package JD.Domain.EFCore

# ASP.NET Core integration
dotnet add package JD.Domain.AspNetCore

# Generators
dotnet add package JD.Domain.DomainModel.Generator
dotnet add package JD.Domain.FluentValidation.Generator

# CLI tool (global install)
dotnet tool install -g JD.Domain.Cli

Complete installation guide →


Contributing

Contributions are welcome! See our contributing guide for details.


License

This project is licensed under the MIT License - see the LICENSE file for details.


  • TinyBDD - BDD testing framework used for testing JD.Domain
  • JD.Efcpt.Build - EF Core reverse engineering tools

Created by Jerrett Davis