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.

Configuring Document Storage

The StoreOptions class is the central configuration object for Polecat. It controls connection settings, schema management, serialization, and more.

Connection String

cs
var store = DocumentStore.For(opts =>
{
    opts.Connection("Server=localhost;Database=myapp;User Id=sa;Password=YourStrong!Password;TrustServerCertificate=True");
});

Schema Name

By default, Polecat uses the dbo schema. You can change this:

cs
opts.DatabaseSchemaName = "myschema";

Auto-Create Schema Objects

Control how Polecat manages database schema:

cs
// Default: CreateOrUpdate - auto-creates and updates tables
opts.AutoCreateSchemaObjects = AutoCreate.CreateOrUpdate;

// CreateOnly - only creates new tables, never modifies existing ones
opts.AutoCreateSchemaObjects = AutoCreate.CreateOnly;

// None - never creates or modifies schema objects
opts.AutoCreateSchemaObjects = AutoCreate.None;

WARNING

In production environments, consider setting AutoCreate.None and managing schema migrations separately.

Table Prefix

All Polecat tables use the pc_ prefix:

  • pc_events -- Event log
  • pc_streams -- Stream metadata
  • pc_event_progression -- Async daemon progression
  • pc_hilo -- HiLo sequence storage
  • pc_doc_{typename} -- Document tables

Store Policies

Apply policies across all document types:

cs
opts.Policies.AllDocumentsSoftDeleted();

opts.Policies.ForDocument<Order>(mapping =>
{
    mapping.DeleteStyle = DeleteStyle.SoftDelete;
});

Listeners

Register global session listeners:

cs
opts.Listeners.Add(new MySessionListener());

See Session Listeners for more details.

Logging

Configure store-level logging:

cs
opts.Logger(new MyPolecatLogger());

HiLo Sequence Defaults

Configure default HiLo sequence settings for numeric identity generation:

cs
opts.HiloSequenceDefaults.MaxLo = 500; // default is 1000

Initial Data Seeding

Register data to be seeded on application startup:

cs
opts.InitialData.Add(async (store, ct) =>
{
    await using var session = store.LightweightSession();
    session.Store(new User { FirstName = "Admin", LastName = "User" });
    await session.SaveChangesAsync(ct);
});

See Initial Baseline Data for more details.

Released under the MIT License.