
A .NET framework, re-imagined as an AI-augmented foundation for enterprise back-end services.
Introduction
CoreEx helps teams build enterprise-grade back-end services faster — without giving up architecture, consistency, or governance.
Built-in AI support already knows CoreEx patterns, conventions, and architecture — powering purpose-built skills and an expert agent that guide delivery toward production-grade, best-practice outcomes, consistently, every time.
CoreEx also addresses the recurring concerns that .NET leaves to each team to solve independently: shaping business rule failures into consistent HTTP responses, publishing and subscribing to domain events and commands, implementing reference data with caching and validity, enforcing validation with structured error messages, and wiring data access across ADO.NET, Entity Framework Core, and Azure Cosmos DB with a shared unit-of-work model.
The solution is composed of focused, independently consumable packages — CoreEx provides the shared runtime primitives, and each additional package (CoreEx.AspNetCore, CoreEx.Events, CoreEx.Database, CoreEx.Validation, etc.) adds a specific capability layer. Teams adopt only what they need.
Overview Video
The following 3-minute video provides an overview of CoreEx — the motivation behind it, its architectural patterns, built-in AI support, and how to get started.
https://github.com/user-attachments/assets/7638294d-9e3c-474a-8e75-7d06cb41eb34
Table of Contents
The remainder of this README is organized into the following sections.
Motivation
CoreEx is intended to be the foundational library for any business-service implementation — the motivation for adopting it comes down to four things:
- Value — focus on business-value delivery; stop re-inventing the same foundational plumbing every time.
- Velocity — reduce delivery time by pairing the framework with agentic AI that builds it for you.
- Consistency — every service looks, builds, and behaves the same way, no matter who is on the team.
- Confidence — improve quality and reduce delivery risk by leaning on capabilities that are proven and tested.
Better Together
The greatest developer velocity gains come not from any single capability, but from the intersection of all three:
- Framework (CoreEx, UnitTestEx, DbEx) — encapsulates proven patterns and complexity into tested, shared components. Every team inherits a consistent, production-hardened baseline rather than rebuilding infrastructure from scratch, maximising reuse and freeing engineers to focus on differentiated business logic.
- Code-generation (CoreEx.Generator, CoreEx.CodeGen, DbEx / OnRamp) — automates the translation of intent into implementation. Roslyn source generation, dev-time scaffolding, and database/entity layer generation combine to produce repetitive layers predictably and consistently every time — deterministic by design — eliminating manual error and accelerating the path from design to working code.
- Gen AI / Copilot — accelerates the development of the unique business value that only your organisation can deliver. AI assistance — probabilistic and context-aware — augments engineers during coding, testing, and review, compressing the feedback loop between idea and production-ready solution.
Where all three converge, the compound effect is multiplicative: the framework constrains the solution space so AI suggestions land in the right patterns; code-generation handles the deterministic heavy lifting so AI can focus on novel logic; and AI in turn accelerates how quickly teams adopt, extend, and validate both.
Design Principles
The following principles shape how CoreEx approaches the problem space:
- Standardize the scenarios .NET leaves open — there is no built-in standard for mapping a
NotFoundException to HTTP 404, expressing a concurrency conflict as a ProblemDetails response, or publishing a domain event transactionally alongside a database commit. CoreEx provides consistent, opinionated implementations of these patterns so every service in an organization behaves the same way.
- Simplify development by eliminating the boilerplate that accumulates around every API endpoint and data operation — execution context scoping, idempotency key handling, paged query translation, outbox relay, ETag management, change-log stamping — freeing teams to focus on business logic rather than infrastructure ceremony.
- Codify established enterprise architectural patterns — DDD aggregates and value objects, layered/hexagonal architecture, CQRS-style read/write separation, the transactional outbox, and Railway-Oriented Programming — as first-class, reusable building blocks instead of bespoke, per-team reinventions.
- Enable flexibility through opt-in modularity and composability — each package is an independent add-on, CoreEx does not mandate an architectural style, and its abstractions (
IMapper, IUnitOfWork, IHybridCache, IEventPublisher) are designed to be replaced or extended without disrupting the rest of the solution.
Key Capabilities
Here is a high-level overview of some of the key capabilities provided by CoreEx:
Core runtime
- 🎯 Semantic Exceptions — Typed exception hierarchy (
NotFoundException, ValidationException, BusinessException, ConcurrencyException, and more) with automatic HTTP status-code mapping and ProblemDetails serialization.
- 🔐 Execution Context — Thread-bound (async-local) request context carrying user identity, tenant, and timestamp; ASP.NET Core middleware integrates it directly into the request pipeline.
- 🔒 Coordination & Idempotency — In-memory coordination for single-process use, renewable synchronization leases, and Redis-backed atomic coordination and retained idempotency outcomes.
- 📦 Entity & DDD Patterns — Composable entity interfaces for identifiers (
IIdentifier<T>), ETags (IETag), change logs (IChangeLog), composite keys, change tracking, aggregate roots with integration-event support, and persistence-state mutation guards.
- 🚂 Railway-Oriented Programming —
Result and Result<T> monadic types for composable, exception-free error flows with full async/await support and short-circuit chaining.
- 💉 Dependency Injection —
[ScopedService], [TransientService], and [SingletonService] attributes with AddDynamicServicesUsing<T> for convention-based registration without manual wiring.
- 🗺️ Mapping & Conversion — Bi-directional
IMapper<TSource, TDestination> contracts, ValueConverter<TSource, TDestination> for EF Core and custom property mapping, and extension-based mapper helpers.
- 🔄 JSON Extensions — Merge-patch (
application/merge-patch+json) support, property-include/exclude filtering, custom JsonConverter types, and JsonSerializer configuration helpers.
Web / API
- 🌐 ASP.NET Core Integration —
WebApi execution helpers for MVC and Minimal API, ExecutionContext scoping middleware, idempotency key handling ([IdempotencyKey]), and exception-to-ProblemDetails translation with consistent error response shaping.
- 📋 OpenAPI / NSwag —
IOperationProcessor that reads CoreEx MVC attributes ([Paging], [Query], [Accepts], [IdempotencyKey], [ProducesNotFoundProblem]) and injects the corresponding parameters, request bodies, and response entries into the generated OpenAPI specification; [NonNullable] describes mandatory nullable DTO properties correctly.
- Typed HTTP Clients — Fluent response validation and cached-result helpers for domain adapters calling other services.
- GraphQL-lite — An opt-in query bridge over existing
QueryArgsConfig and paging, with JSON field projection rather than a separate resolver/filter implementation.
Data
- ✅ Validation Framework — Fluent, property-centric validator with composable rules, conditional clauses, async predicates,
RuleSet grouping, base-validator include, FluentValidation interop bridge, and deep ValidationException / ProblemDetails integration.
- 📊 Data Access & OData-style Querying —
QueryArgsConfig, QueryFilterParser, and QueryOrderByParser for safe, explicitly-configured $filter and $orderby LINQ translation; query arguments, paging, partitioning, logical deletion, and IUnitOfWork transactional orchestration.
- 🗄️ Database & ORM —
IDatabase / DatabaseCommand ADO.NET abstraction with multi-result-set support, transactional outbox relay infrastructure, SQL Server and PostgreSQL implementations with OpenTelemetry metrics, and an Entity Framework Core integration layer with typed CRUD operations and ValueConverter bridges.
- Azure Cosmos DB — Typed CRUD/query access with ETags, multi-tenancy, logical deletion, scoped snapshot tracking, a transactional-batch outbox, and change-feed relaying with backlog replay on fresh leases.
- 📚 Reference Data — Typed
ReferenceData<TSelf> / ReferenceData<TId, TSelf> base classes, thread-safe collections, hybrid caching and date validity; opt-in generated mutation APIs backed by EF Core or Cosmos, with validation and post-commit cache invalidation.
- ⚡ Hybrid Caching —
IHybridCache abstraction with FusionHybridCache (ZiggyCreatures FusionCache) as the recommended implementation, providing L1/L2 hybrid storage and backplane-based cache invalidation.
Messaging
- 📨 Event Publishing & Subscribing —
EventData ↔ CloudEvents formatting, a two-phase queue-then-publish pipeline, and configurable subscriber dispatch with per-subscriber structured error handling and dead-letter support.
- 🚌 Azure Service Bus —
ServiceBusPublisher implementing IEventPublisher, named routing of commands to per-domain queues while events stay on a shared topic, keyed receivers, resiliency, OpenTelemetry metrics, and independently configurable per-destination session policies.
- Partitioning Boundaries — Shared partition sizing across relational outbox writers and relays, deterministic keyless routing, and separate Service Bus session grouping; consumer concurrency and broker partitions are distinct concerns.
Tooling
- File Processing —
CoreEx.IO provides host-neutral CSV flat/routed/hierarchical and nested JSONL validation through one shared lifecycle, streamed diagnostics, optional awaited unit observation in all three modes, and scoped execution. ValidateThenExecute waits for whole-file acceptance; ValidateAndExecute deliberately permits partial writes. JSONL supports opt-in metadata routes, strict native scalars, and nested cardinality. File CodeGen generates typed integrations from *-file.yaml; the host owns immutable replay and durable business idempotency. JSON document/XML readers are not implemented.
- 🏗️ Reference Data Code Generation — Development-time
CoreEx.CodeGen tooling that scaffolds contracts, read providers/controllers, repositories and mappers, plus opt-in mutation services/controllers, from a single schema-validated ref-data.yaml configuration file.
- Provisioning & Scaffolding — Composable
CoreEx.Template solution/host/AI templates, relational database lifecycle tooling, and a Cosmos provisioning console for declared containers and seed data.
- 🧪 Testing Toolkit —
CoreEx.UnitTesting provides fluent expectations, event/outbox assertions (SQL Server, PostgreSQL, Cosmos, Azure Service Bus), JSON/YAML seeds, and Aspire E2E lifecycle helpers with real cross-domain hosts and a WireMock host for third-party HTTP.
Patterns in Practice
The capabilities above come to life in the Contoso reference samples, which implement a fully working multi-domain service topology. The samples are the primary demonstration of why CoreEx exists — they show how the packages compose into a coherent, production-shaped architecture.
The Pattern Catalog is the best entry point: it indexes every architectural and design pattern demonstrated across the samples, grouped by concern, each linked to the layer documentation that shows it in code.
| Group |
Patterns demonstrated |
| 🏛️ Architecture |
Domain microservices, event-driven architecture (async-primary, sync-selective), hexagonal architecture, eventual consistency |
| 🌐 API |
Thin-controller HTTP endpoints, idempotency keys |