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.

Introduction

Welcome to the Polecat documentation!

What is Polecat?

Polecat is a .NET library for building applications using a document-oriented database approach and Event Sourcing, backed by SQL Server 2025.

Polecat is part of the Critter Stack ecosystem and mirrors the API patterns of Marten (the PostgreSQL equivalent), making it easy for teams already familiar with Marten to adopt SQL Server as their backing store.

TIP

If you've used Marten before, you'll feel right at home with Polecat. The API surface is intentionally similar -- same interface names, same session patterns, same projection model.

Under the hood, Polecat is built on top of SQL Server 2025, leveraging its native JSON type to provide:

Polecat uses SQL Server 2025's native JSON data type for storing document bodies, event data, headers, and snapshots. Combined with modern T-SQL features, this provides strong data consistency for both document storage and event sourcing approaches.

Main Features

FeatureDescription
Document StorageStore your entities as JSON documents in SQL Server with full LINQ querying support.
Event StoreFull-fledged event store for Event Sourcing with stream management, projections, and subscriptions.
Strong ConsistencyUses SQL Server transactions for ACID compliance across both document and event operations.
LINQ QueryingFilter documents using LINQ queries with string searching, child collection queries, paging, and more.
Event ProjectionsBuild read models from events using inline, async, or live projection strategies.
Automatic Schema ManagementPolecat manages SQL Server table creation and migrations automatically via Weasel.SqlServer.
Optimistic ConcurrencyBuilt-in support for both Guid-based and numeric revision concurrency control.
Multi-TenancyMultiple tenancy strategies: conjoined (same tables), separate databases, or single tenant.
Async DaemonBackground projection processing for eventually consistent read models.
EF Core IntegrationUse Entity Framework Core DbContext within your event projections.

Critter Stack Ecosystem

Polecat is designed to work alongside other Critter Stack libraries:

LibraryPurpose
MartenPostgreSQL document database and event store
WolverineMessaging and command processing framework
JasperFxCore framework and event sourcing abstractions
WeaselDatabase schema management

Polecat vs Marten

Polecat mirrors Marten's API but targets SQL Server 2025 instead of PostgreSQL:

FeatureMarten (PostgreSQL)Polecat (SQL Server)
JSON storagejsonb typejson type (SQL Server 2025)
Sequencesbigserial / sequencesbigint IDENTITY(1,1)
UpsertINSERT ... ON CONFLICTMERGE statement
Change notificationLISTEN/NOTIFYPolling (configurable interval)
Advisory lockspg_advisory_locksp_getapplock / sp_releaseapplock
Timestampstimestamptzdatetimeoffset
SerializationSTJ or NewtonsoftSystem.Text.Json only

History and Origins

The project name Polecat follows the Critter Stack tradition of naming projects after animals. A polecat is a member of the mustelid family -- close relatives of the marten, making it a fitting name for Marten's SQL Server cousin.

Released under the MIT License.