Chronicles 0.9.2

dotnet add package Chronicles --version 0.9.2
                    
NuGet\Install-Package Chronicles -Version 0.9.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Chronicles" Version="0.9.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Chronicles" Version="0.9.2" />
                    
Directory.Packages.props
<PackageReference Include="Chronicles" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Chronicles --version 0.9.2
                    
#r "nuget: Chronicles, 0.9.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Chronicles@0.9.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Chronicles&version=0.9.2
                    
Install as a Cake Addin
#tool nuget:?package=Chronicles&version=0.9.2
                    
Install as a Cake Tool

Chronicles

Event sourcing and CQRS for .NET, backed by Azure Cosmos DB. Chronicles gives you append-only event streams, command handlers, state projections, and document projections — production-ready infrastructure you'd otherwise spend months building yourself.

CI NuGet Branch Coverage Line Coverage Method Coverage

Install

dotnet add package Chronicles

Quick start

// Define your events
record OrderPlaced(string OrderId, string CustomerId, decimal Total);
record OrderShipped(string OrderId, DateTimeOffset ShippedAt);

// Write events to a stream
var streamId = new StreamId("order", orderId);

await writer.WriteAsync(streamId, [
    new OrderPlaced(orderId, customerId, 49.99m),
]);

// Later: append more events
await writer.WriteAsync(streamId, [
    new OrderShipped(orderId, DateTimeOffset.UtcNow),
]);

// Read events back
await foreach (var evt in reader.ReadAsync(streamId))
{
    Console.WriteLine($"{evt.Metadata.Name} at {evt.Metadata.Timestamp}");
}

Three pillars

Event Store

Append-only, immutable event streams persisted to Azure Cosmos DB with optimistic concurrency control.

Type Role
StreamId Identifies a stream by category + id (e.g., "order.42")
IEventStreamWriter Appends events, closes streams, manages checkpoints
IEventStreamReader Reads events, queries streams, retrieves checkpoints

Events are your source of truth — immutable facts stored permanently.

CQRS

Command handlers validate business rules, emit events, and rebuild aggregate state from event history.

Type Role
ICommandHandler<TCommand, TState> Handles a command with full state projection
IStatelessCommandHandler<TCommand> Handles a command without replaying all events
IStateProjection<TState> Folds a stream of events into aggregate state
// Implement a stateful command handler
public class ShipOrderHandler : ICommandHandler<ShipOrder, OrderState>
{
    public OrderState CreateState(StreamId streamId) => new();

    public OrderState? ConsumeEvent(StreamEvent evt, OrderState state) =>
        evt.Data switch
        {
            OrderPlaced p => state with { CustomerId = p.CustomerId, Total = p.Total },
            _ => null,
        };

    public async ValueTask ExecuteAsync(
        ICommandContext<ShipOrder> context,
        OrderState state,
        CancellationToken cancellationToken)
    {
        if (state.CustomerId is null)
            throw new InvalidOperationException("Order does not exist.");

        context.AddEvent(new OrderShipped(context.Command.OrderId, DateTimeOffset.UtcNow));
    }
}

Document Store

Read-model projections driven by the Cosmos DB change feed — query-optimized, denormalized views.

Type Role
IDocumentProjection<TDocument> Projects events into a Cosmos read-model document
IDocumentWriter<T> Creates, updates, replaces, and deletes documents
IDocumentReader<T> Queries documents from Cosmos

Build fast read-side queries without CQRS complexity if you don't need it.

Sample

The sample/ directory contains a food-delivery microservices demo built with .NET Aspire. It covers three bounded contexts — Orders, Restaurants, and Couriers — and shows how to wire up event streams, command handlers, and document projections end-to-end.

Documentation

Guide Description
Getting Started Install Chronicles, configure DI, and write your first events
Event Store Streams, versioning, optimistic concurrency, and checkpoints
Command Handlers Stateless, stateful, and selective-state handler patterns
Projections State projections, document projections, and commit actions
Document Store Reading and writing Cosmos documents with IDocumentReader / IDocumentWriter
Event Subscriptions Change-feed subscriptions and event processors
Event Evolution Schema evolution, event aliases, upcasting, and fault-tolerant deserialization
Dependency Injection Full DI reference: AddChronicles, event store, CQRS, subscriptions
Testing AddFakeChronicles, in-memory fakes, and xUnit test patterns

Contributing & community

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.9.2 454 3/25/2026
0.9.1 102 3/25/2026
0.9.0 130 3/18/2026