Skip to content

The search box knows all the secrets -- try it!

Polecat is part of the Critter Stack ecosystem.

JasperFx Logo JasperFx provides formal support for Polecat and other Critter Stack libraries. Please check our Support Plans for more details.

Polecat as Event Store

Polecat provides a full-featured event store built on SQL Server 2025, following the same patterns as Marten's PostgreSQL-based event store.

Key Concepts

  • Event -- An immutable record of something that happened in your domain
  • Stream -- A sequence of events related to a specific aggregate or entity
  • Aggregate -- A domain object whose state is derived by replaying events
  • Projection -- A read model built from events, either inline, live, or asynchronously

Event Store Tables

Polecat uses three core tables (all prefixed with pc_):

TablePurpose
pc_eventsAll events with sequence IDs, stream references, JSON data
pc_streamsStream metadata: version, type, timestamps, snapshots
pc_event_progressionAsync daemon progress tracking per projection

Stream Identity

Streams can be identified by either Guid or string:

cs
var store = DocumentStore.For(opts =>
{
    opts.Connection("...");

    // Default: Guid stream IDs
    opts.Events.StreamIdentity = StreamIdentity.AsGuid;

    // Alternative: String stream IDs
    opts.Events.StreamIdentity = StreamIdentity.AsString;
});

Quick Example

cs
// Define events
public record InvoiceCreated(decimal Amount, string Customer);
public record InvoicePaid(decimal AmountPaid, DateTimeOffset PaidAt);

// Append events
await using var session = store.LightweightSession();
var streamId = session.Events.StartStream<Invoice>(
    new InvoiceCreated(100m, "Acme Corp"),
    new InvoicePaid(100m, DateTimeOffset.UtcNow)
);
await session.SaveChangesAsync();

// Replay to aggregate
var invoice = await session.Events.AggregateStreamAsync<Invoice>(streamId);

See the Quick Start for a complete walkthrough.

Projection Strategies

StrategyWhen AppliedUse Case
InlineSame transaction as event appendStrong consistency requirements
LiveOn-demand replayOccasional reads, always current
AsyncBackground daemonEventually consistent read models

Event Appending

Polecat uses QuickAppend -- direct SQL INSERT statements with an UPDATE...OUTPUT pattern for version management. No stored procedures are used.

See Appending Events for details.

Released under the MIT License.