PouryaKit.Persistence.Marten 0.1.0-preview.2

This is a prerelease version of PouryaKit.Persistence.Marten.
dotnet add package PouryaKit.Persistence.Marten --version 0.1.0-preview.2
                    
NuGet\Install-Package PouryaKit.Persistence.Marten -Version 0.1.0-preview.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="PouryaKit.Persistence.Marten" Version="0.1.0-preview.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PouryaKit.Persistence.Marten" Version="0.1.0-preview.2" />
                    
Directory.Packages.props
<PackageReference Include="PouryaKit.Persistence.Marten" />
                    
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 PouryaKit.Persistence.Marten --version 0.1.0-preview.2
                    
#r "nuget: PouryaKit.Persistence.Marten, 0.1.0-preview.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 PouryaKit.Persistence.Marten@0.1.0-preview.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=PouryaKit.Persistence.Marten&version=0.1.0-preview.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=PouryaKit.Persistence.Marten&version=0.1.0-preview.2&prerelease
                    
Install as a Cake Tool

PouryaKit.Persistence.Marten

NuGet .NET 10 License: MIT

PouryaKit.Persistence.Marten

Streams on Marten over PostgreSQL: the Kit's second write model. A Stream is an aggregate whose stored state is the events it appended. A behaviour applies its event to the aggregate's state and raises it, the Unit of Work appends what was raised, and loading the Stream folds its stored events through the same Apply methods.

Install

dotnet add package PouryaKit.Persistence.Marten --prerelease

When to use it

  • An aggregate's history is the point: a ledger, an account, an audit of every change.
  • You register a Stream Module, beside EF Core Modules or without them.
  • You load and start Streams in a handler, and handle a concurrent append as a conflict.

A Host with a message store adds PouryaKit.Messaging.Wolverine.Marten, which commits a Stream's events with what it sends. PouryaKit.Persistence.Postgres is the other write model.

Quick start

Declare the write model in the Module's Composition Root:

module.AddPouryaKitStreams(schema: "ledger");

Write behaviour as events, as the Proving Sample's Ledger does:

internal sealed class Account : StreamAggregate
{
    public string Holder { get; private set; } = "";

    public decimal Balance { get; private set; }

    public void Post(decimal amount)
    {
        var posted = new EntryPostedDomainEvent(new AccountId(Id), amount);
        Apply(posted);
        Raise(posted);
    }

    public void Apply(EntryPostedDomainEvent posted) => Balance += posted.Amount;
}

Load and change a Stream in the handler through IStreams:

internal sealed class PostEntryCommandHandler(IStreams streams) : CommandHandler<PostEntryCommand>
{
    public override async Task<Result> Handle(
        PostEntryCommand command,
        CancellationToken cancellationToken
    )
    {
        if (
            await streams.LoadAsync<Account>(new AccountId(command.AccountId), cancellationToken)
            is not { } account
        )
        {
            return AccountErrors.NotFound;
        }

        account.Post(command.Amount);
        return Result.Success();
    }
}

What you get

  • A Stream Module that is still a Module: the same Gateway, pipeline and Notification Handlers.
  • One commit owner per write model, so each Operation commits through exactly one.
  • A concurrent append refused as a conflict Error, with nothing appended.
  • A Stream that belongs to the tenant of the Operation that wrote it.

A Stream publishes no Snapshot and has no plain-SQL connection, realtime push or number sequence, and it cannot share one Host with a Saga yet.

Learn more

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 (1)

Showing the top 1 NuGet packages that depend on PouryaKit.Persistence.Marten:

Package Downloads
PouryaKit.Messaging.Wolverine.Marten

A Stream's messages sent through Wolverine's Marten outbox, so its events commit with the Notifications and Integration Events they cause.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-preview.2 71 11/1/2026
0.1.0-preview.1 76 10/31/2026
0.1.0-preview.0.28 75 10/26/2026