Memoria.EventSourcing.Store.Cosmos
2.0.0
Prefix Reserved
dotnet add package Memoria.EventSourcing.Store.Cosmos --version 2.0.0
NuGet\Install-Package Memoria.EventSourcing.Store.Cosmos -Version 2.0.0
<PackageReference Include="Memoria.EventSourcing.Store.Cosmos" Version="2.0.0" />
<PackageVersion Include="Memoria.EventSourcing.Store.Cosmos" Version="2.0.0" />
<PackageReference Include="Memoria.EventSourcing.Store.Cosmos" />
paket add Memoria.EventSourcing.Store.Cosmos --version 2.0.0
#r "nuget: Memoria.EventSourcing.Store.Cosmos, 2.0.0"
#:package Memoria.EventSourcing.Store.Cosmos@2.0.0
#addin nuget:?package=Memoria.EventSourcing.Store.Cosmos&version=2.0.0
#tool nuget:?package=Memoria.EventSourcing.Store.Cosmos&version=2.0.0
Memoriaβ’
Event sourcing for .NET with two consistency models in one framework. Store state as classic event streams, or as dynamic consistency boundaries where the boundary is a tag query chosen per decision. Start with the mediator alone and add an event store when you need one β nothing forces you to take both.
From Latin memoria (memory).
π Documentation Β· π Getting started Β· π‘ Concepts Β· π§ Guides Β· π Reference
π Examples Β· β¬οΈ Upgrading Β· π£ Release notes
π Licence at a glance
The framework is free and open source under the Apache License 2.0 β
every package under the Memoria NuGet prefix, every version. Use it in anything, commercial or
not, closed source or open, at any scale. No edition, no threshold, no key, nothing to sign.
StateLens, the browser tool that reads a store through your own domain assemblies and a manifest, is a separate product developed in its own repository: commercial, free for a single service and paid above that, under its own licence. Nothing in this repository is part of it, and installing the packages never requires it.
Already on 1.x? Upgrade to 2.0.0 walks through the two behaviours that move with the major version. Nothing in the store changes, so there is no data migration.
π₯ Install
dotnet add package Memoria
Only Memoria is required. Add an event-sourcing package and a store when you need one:
dotnet add package Memoria.EventSourcing
dotnet add package Memoria.EventSourcing.Store.EntityFrameworkCore
The install guide explains when to reach for each of the packages listed below.
π Quickstart
Register what you need at startup:
services.AddMemoria(typeof(Program)); // Mediator: commands, queries, notifications
services.AddMemoriaEventSourcing(typeof(Program)); // Aggregates, streams, projections
services.AddMemoriaEntityFrameworkCore<MyDbContext>(); // Store
As a mediator
public record CreateProduct(string Name) : ICommand;
public class CreateProductHandler : ICommandHandler<CreateProduct>
{
public Task<Result> Handle(CreateProduct command, CancellationToken cancellationToken = default) =>
Task.FromResult(Result.Ok());
}
await dispatcher.Send(new CreateProduct("Espresso"));
See the Mediator quickstart
for queries, notifications, validation, custom handlers, command sequences and SendAndPublish.
As an event store
[EventType("OrderPlaced")]
public record OrderPlacedEvent(Guid OrderId, decimal Amount) : IEvent;
var streamId = new CustomerStreamId(customerId);
var aggregateId = new OrderId(orderId);
var order = new Order(orderId, amount: 25.45m);
await domainService.SaveAggregate(streamId, aggregateId, order, expectedEventSequence: 0);
See the Event Sourcing quickstart for the full aggregate definition, and Streams or DCB? for choosing a consistency model.
Past that, the guides cover one task each, and
the reference has the
IDomainService API and a
configuration page per package.
β‘ What you get
| Area | Capabilities |
|---|---|
| Mediator | Commands, queries and notifications through one IDispatcher; command sequences; custom handlers in place of the resolved one; automatic notification publication after a command succeeds; Result instead of exceptions |
| Consistency | Event streams with optimistic concurrency on an expected event sequence, or dynamic consistency boundaries where the boundary is a tag query chosen per decision; multiple aggregates per stream |
| Reads | Four read modes; aggregate snapshots stored alongside events for fast, strongly consistent reads; projections persisted and retrieved as snapshots; in-memory reconstruction up to a given sequence or date |
| Event queries | Filter applied events by event type, or by event property declared as key/value pairs on the aggregate id; query stream events from or up to a sequence, date or date range; retrieve every event applied to an aggregate |
| Providers | Stores: EF Core (plus ASP.NET Identity and PostgreSQL jsonb companions), Cosmos DB. Messaging: Azure Service Bus, RabbitMQ. Caching: in-memory, Redis. Validation: FluentValidation |
| Testing | In-memory variants of Cosmos DB, Service Bus and RabbitMQ, so a test suite needs no external dependency |
| Tooling | StateLens β a separate browser tool that reads any framework's store through your own domain assemblies and a manifest |
π StateLens
StateLens is a browser tool for reading an event sourced store. Point it
at a store, upload a zip of your own domain assemblies β with a statelens.json at its root
naming the services in it β and it shows you the events that were appended, the aggregates and
projections snapshotted from them, and the types both were written through. Open a row and the
aggregate is folded from its events, so you can see the state a snapshot stands at and how far
behind its history it is. It creates nothing and deletes nothing.
It began here, as Memoria Web, a reader of Memoria stores. It lives in its own repository now, which is private, and reads any framework's store, not only Memoria's: a service's manifest tells the tool which uploaded types are the streams, events, aggregates and projections, how they are named and folded, and where in the store the events and snapshots are. Memoria's own stores are described the same way as anyone else's.
It is a commercial product, separate from the framework: free over a single service, and paid above that, under the StateLens Licence. Its documentation is on its site, and a hosted instance at demo.statelens.dev is open by invitation, asked for through the site's contact form.
π¦ Packages
Every package is published at the same version, so one number fits the whole set.
| Package | Version | What it adds |
|---|---|---|
| Memoria | Required. Mediator core: commands, queries, notifications, dispatcher | |
| Memoria.EventSourcing | Aggregates, streams, projections and IDomainService |
|
| Memoria.EventSourcing.Dcb | Dynamic consistency boundaries | |
| Memoria.EventSourcing.Dcb.Store.EntityFrameworkCore | EF Core store for the DCB model | |
| Memoria.EventSourcing.Store.EntityFrameworkCore | EF Core store: SQL Server, SQLite, PostgreSQL, MySQL, in-memory | |
| Memoria.EventSourcing.Store.EntityFrameworkCore.Identity | The above, plus ASP.NET Core Identity in the same DbContext |
|
| Memoria.EventSourcing.Store.EntityFrameworkCore.Npgsql | PostgreSQL jsonb-aware event-property filtering |
|
| Memoria.EventSourcing.Store.Cosmos | Azure Cosmos DB store (SQL API) | |
| Memoria.EventSourcing.Store.Cosmos.InMemory | In-process Cosmos DB stand-in for tests | |
| Memoria.Messaging.ServiceBus | Publish to Azure Service Bus when a command succeeds | |
| Memoria.Messaging.ServiceBus.InMemory | In-process Service Bus stand-in for tests | |
| Memoria.Messaging.RabbitMq | Publish to RabbitMQ when a command succeeds | |
| Memoria.Messaging.RabbitMq.InMemory | In-process RabbitMQ stand-in for tests | |
| Memoria.Caching.Memory | Cache query results in-process | |
| Memoria.Caching.Redis | Cache query results in Redis | |
| Memoria.Validation.FluentValidation | Validate commands before they reach the handler |
πΊοΈ Roadmap
Shipped work is in the release notes. Next up, in no fixed order:
- Pipelines
- Option to automatically validate commands
- Event Grid messaging provider
- Kafka messaging provider
- Amazon SQS messaging provider
- File store provider for event sourcing
π€ Contributing
Bug reports, questions and feature requests are welcome as issues and discussions. For code, please open an issue first, and read CONTRIBUTING.md β it covers how to build and test and the conventions to follow. There is nothing to sign: the framework is Apache 2.0, and a contribution comes in under the same terms it goes out under.
By taking part you agree to the Code of Conduct.
β Give a star
If Memoria is useful in your learning, samples, workshop or project, please give the repository a star. Thank you!
β¨ Custom implementations and project support
Memoria is designed to be extended, with providers for store, messaging, caching and validation.
Need a provider that does not exist yet β a custom database store, a different message bus β or help applying Memoria to an existing codebase? Get in touch via LinkedIn.
π Licence
The framework is under the Apache License 2.0 β
every package published under the Memoria NuGet prefix, every version, 1.x and 2.x alike. Build
whatever you like with it, licence that however you like, ship it to whomever you like. The full
text is in LICENSE.md.
StateLens is a commercial product, developed in its own private repository and licensed separately under the StateLens Licence. Running it is what the licence governs, metered by services β a named set of domain assemblies read over one connection string. One service is free, and always will be; above that it is priced by how many services one instance reads, on the tool's pricing page, with no limit on people, instances or environments. Nothing of it is in this repository.
Version 2.0.0-beta was briefly offered under the Reciprocal Public License 1.5 or a commercial licence covering the packages. That was withdrawn four days later at 2.0.0-beta.2, the framework returned to Apache 2.0, where it had been throughout 1.x, and 2.0.0 shipped under it. Anyone who took 2.0.0-beta under the earlier terms keeps them; Apache 2.0 grants strictly more.
| Product | Versions 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. |
-
net10.0
- Memoria (>= 2.0.0)
- Memoria.EventSourcing (>= 2.0.0)
- Microsoft.AspNetCore.Http (>= 2.3.13)
- Microsoft.Azure.Cosmos (>= 3.63.0)
- Microsoft.Extensions.Options (>= 10.0.12)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Memoria.EventSourcing.Store.Cosmos:
| Package | Downloads |
|---|---|
|
Memoria.EventSourcing.Store.Cosmos.InMemory
DDD, CQRS and Event Sourcing framework for .NET. Use it as a plain mediator, or as an event store with classic event streams or dynamic consistency boundaries. Licensed under the Apache License 2.0. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.0 | 165 | 10/7/2026 |
| 2.0.0-beta.2 | 421 | 9/21/2026 |
| 2.0.0-beta | 91 | 9/16/2026 |
| 1.9.1 | 127 | 9/13/2026 |
| 1.9.0 | 107 | 9/12/2026 |
| 1.8.0 | 137 | 9/4/2026 |
| 1.8.0-beta-2 | 114 | 9/3/2026 |
| 1.8.0-beta | 114 | 9/2/2026 |
| 1.7.0 | 122 | 8/31/2026 |
| 1.6.0 | 122 | 8/30/2026 |
| 1.5.0 | 118 | 8/29/2026 |
| 1.4.1 | 119 | 8/25/2026 |
| 1.4.0 | 125 | 8/23/2026 |
| 1.3.2 | 155 | 5/16/2026 |
| 1.3.1 | 152 | 5/13/2026 |
| 1.3.0 | 138 | 5/13/2026 |
| 1.2.1 | 143 | 5/12/2026 |
| 1.2.0 | 154 | 5/10/2026 |
| 1.1.0 | 171 | 2/1/2026 |
| 1.0.0 | 232 | 10/10/2025 |