This document provides a complete reference for WitDatabase connection string parameters. Connection strings are used with ADO.NET provider and Entity Framework Core.
Basic Format
Data Source=path/to/database.witdb;Property1=Value1;Property2=Value2
Rules:
- Property names are case-insensitive (
Data Source=data source=DATA SOURCE) - Values with spaces or semicolons must be quoted:
Password="my;secret" - Boolean values:
true/false,yes/no,1/0 - Use forward slashes
/or escaped backslashes\\in paths
Quick Examples
// Minimal
"Data Source=app.witdb"
// In-memory (testing)
"Data Source=:memory:"
// With encryption
"Data Source=secure.witdb;Encryption=aes-gcm;Password=MySecret123!"
// High-performance writes (LSM-Tree)
"Data Source=/data/logs;Store=lsm;Sync Writes=false"
// Read-only access
"Data Source=archive.witdb;Mode=ReadOnly;Cache Size=10000"
// Production with pooling
"Data Source=/var/app/data.witdb;Encryption=aes-gcm;Password=***;Pooling=true;Max Pool Size=50"
Core Properties
| Property | Alias | Type | Default | Description |
|---|---|---|---|---|
Data Source |
DataSource |
string | required | Path to database file or :memory: |
Mode |
— | enum | ReadWriteCreate |
Access mode |
Read Only |
ReadOnly |
bool | false |
Shortcut for Mode=ReadOnly |
Data Source
// File-based database
"Data Source=myapp.witdb"
"Data Source=C:\\Data\\myapp.witdb"
"Data Source=/var/lib/myapp/data.witdb"
// In-memory (non-persistent)
"Data Source=:memory:"
// Relative path
"Data Source=./data/app.witdb"
Mode
| Value | Description |
|---|---|
ReadWriteCreate |
Open or create database (default) |
ReadWrite |
Open existing, fail if not exists |
ReadOnly |
Open read-only, fail if not exists |
Memory |
In-memory database (same as :memory:) |
"Data Source=app.witdb;Mode=ReadOnly"
"Data Source=app.witdb;Read Only=true" // Equivalent
"Data Source=temp;Mode=Memory" // In-memory
Storage Engine
| Property | Type | Default | Values |
|---|---|---|---|
Store |
enum | btree |
btree, lsm, inmemory |
Engine Comparison
| Engine | Best For | Characteristics |
|---|---|---|
btree |
General purpose, read-heavy | Balanced read/write, single file, good for OLTP |
lsm |
Write-heavy, time-series, logs | Fast sequential writes, directory-based, background compaction |
inmemory |
Testing, temporary data | No persistence, maximum speed |
// B+Tree (default) — general purpose
"Data Source=app.witdb;Store=btree"
// LSM-Tree — write-optimized
"Data Source=logs.witdb;Store=lsm"
// In-memory — testing
"Data Source=:memory:;Store=inmemory"
Tip: Start with
btree. Switch tolsmonly if you have write-heavy workloads (>80% writes) or time-series data.
Encryption
| Property | Type | Default | Description |
|---|---|---|---|
Encryption |
enum | none |
Encryption algorithm |
Password |
string | — | Encryption password (required if encryption enabled) |
User |
string | — | Username for key derivation (multi-tenant scenarios) |
Fast Encryption |
bool | false |
Use faster PBKDF2 iterations (for Blazor WASM) |
Encryption Algorithms
| Value | Algorithm | Notes |
|---|---|---|
none |
No encryption | Default |
aes-gcm |
AES-256-GCM | Recommended, hardware-accelerated on modern CPUs |
chacha20-poly1305 |
ChaCha20-Poly1305 | Requires OutWit.Database.Core.BouncyCastle package |
Examples
// Simple password encryption
"Data Source=secure.witdb;Encryption=aes-gcm;Password=MySecretPassword123!"
// Multi-tenant (different keys per user)
"Data Source=multi.witdb;Encryption=aes-gcm;User=tenant1;Password=TenantPass123"
// ChaCha20 for Blazor WASM or ARM without AES-NI
"Data Source=app.witdb;Encryption=chacha20-poly1305;Password=MyPassword"
// Fast encryption for Blazor WASM (fewer PBKDF2 iterations)
"Data Source=wasm.witdb;Encryption=aes-gcm;Password=WasmPass;Fast Encryption=true"
Security Warning: Never hardcode passwords in source code. Use environment variables, configuration files, or secrets management (Azure Key Vault, AWS Secrets Manager).
// Good: from environment
var password = Environment.GetEnvironmentVariable("DB_PASSWORD");
Loading...
quot;Data Source=app.witdb;Encryption=aes-gcm;Password={password}"
// Good: from configuration
var password = Configuration["Database:Password"];
Caching
Property
Alias
Type
Default
Description
Cache
—
enum
clock
Cache eviction algorithm
Cache Size
CacheSize
int
1000
Number of cached pages
Page Size
PageSize
int
4096
Page size in bytes (4096–65536)
Cache Algorithms
Value
Algorithm
Best For
clock
Clock (Second-Chance)
Default, good general performance
lru
Least Recently Used
Sequential access patterns, analytics
Tuning Guidelines
Scenario
Cache Size
Page Size
Small app, limited memory
500–1000
4096
General purpose
1000–5000
4096
Large datasets, lots of RAM
5000–20000
8192
Large BLOBs (images, files)
1000–5000
16384–65536
Blazor WASM (browser)
200–500
4096
// Default caching
"Data Source=app.witdb"
// Large cache for read-heavy workload
"Data Source=app.witdb;Cache Size=10000"
// Large page size for BLOB storage
"Data Source=files.witdb;Page Size=16384;Cache Size=2000"
// Memory-constrained (Blazor WASM)
"Data Source=app.witdb;Cache Size=300;Page Size=4096"
Memory formula: Cache Size × Page Size ≈ cache memory usage.
Example: 5000 pages × 4096 bytes = ~20 MB
Transactions
Property
Alias
Type
Default
Description
Transactions
—
bool
true
Enable ACID transactions
MVCC
—
bool
true
Enable Multi-Version Concurrency Control
Isolation Level
IsolationLevel
enum
ReadCommitted
Default isolation level
Journal
Journal Mode
enum
wal
Transaction journal mode
Isolation Levels
Level
Dirty Reads
Non-Repeatable
Phantoms
Performance
Use Case
ReadUncommitted
Yes
Yes
Yes
Fastest
Approximate counts, monitoring
ReadCommitted
No
Yes
Yes
Fast
Default, most applications
RepeatableRead
No
No
Yes
Medium
Reports needing consistent reads
Serializable
No
No
No
Slowest
Financial transactions
Snapshot
No
No
No
Fast
Read-heavy with consistency
Recommendation: Use Snapshot for read-heavy workloads with MVCC. It provides strong consistency without blocking readers.
Journal Modes
Mode
Description
Durability
Performance
wal
Write-Ahead Logging
High
Better concurrent reads
rollback
Rollback Journal
High
Simpler, less disk space
// Default (transactions enabled, ReadCommitted)
"Data Source=app.witdb"
// Snapshot isolation (recommended for read-heavy)
"Data Source=app.witdb;Isolation Level=Snapshot"
// Disable transactions (maximum performance, no ACID guarantees)
"Data Source=cache.witdb;Transactions=false"
// Disable MVCC (single-writer scenarios)
"Data Source=app.witdb;MVCC=false"
// Rollback journal instead of WAL
"Data Source=app.witdb;Journal=rollback"
Concurrency
Property
Alias
Type
Default
Description
File Locking
FileLocking
bool
true
Enable OS-level file locking
Lock Timeout
LockTimeout
int
30
Lock timeout in seconds
Parallel Mode
ParallelMode
enum
None
Parallel write mode
Max Writers
MaxWriters
int
CPU count
Maximum concurrent writers
Parallel Mode
Value
Description
Use Case
None
Single writer (default)
Most applications
Auto
Automatically choose strategy
Recommended for parallel
Buffered
Buffer writes, batch commit
High-throughput inserts
Latched
Page-level latching
Mixed read/write
Optimistic
Optimistic concurrency
Low contention
// Default (single writer, file locking)
"Data Source=app.witdb"
// Disable file locking (single-process only!)
"Data Source=app.witdb;File Locking=false"
// Custom lock timeout (60 seconds)
"Data Source=app.witdb;Lock Timeout=60"
// Parallel writes for high-throughput
"Data Source=app.witdb;Parallel Mode=Auto;Max Writers=8"
Warning: Only disable file locking if you guarantee single-process access. Multiple processes without locking will corrupt the database.
Common Scenarios
Development / Testing
// Simple file database
"Data Source=dev.witdb"
// In-memory for unit tests
"Data Source=:memory:"
Web Application (ASP.NET Core)
// With encryption and connection pooling
"Data Source=/var/app/data.witdb;Encryption=aes-gcm;Password=***;Pooling=true;Max Pool Size=50;Isolation Level=Snapshot"
Desktop Application
// User-specific encrypted database
var appData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
Loading...
quot;Data Source={appData}/MyApp/data.witdb;Encryption=aes-gcm;Password={userPassword}"
Read-Only Analytics
// Large cache, LRU for sequential scans
"Data Source=analytics.witdb;Mode=ReadOnly;Cache Size=20000;Cache=lru"
Blazor WebAssembly
// Optimized for browser: small cache, fast encryption
"Data Source=app.witdb;Encryption=aes-gcm;Password=***;Fast Encryption=true;Cache Size=300"
LSM-Tree Configuration
These parameters only apply when Store=lsm. LSM-Tree is optimized for write-heavy workloads.
Property
Alias
Type
Default
Description
MemTable Size
MemTableSize, LSM MemTable Size
int
4194304
MemTable size in bytes (4 MB)
Block Cache Size
BlockCacheSize, LSM Block Cache Size
int
67108864
Block cache in bytes (64 MB)
Sync Writes
SyncWrites, LSM Sync
bool
true
Sync WAL to disk on each write
Background Compaction
BackgroundCompaction, LSM Background Compaction
bool
true
Enable background compaction
LSM WAL
—
bool
true
Enable Write-Ahead Log
LSM Block Size
—
int
4096
SSTable block size
LSM Compaction Trigger
—
int
4
Level-0 files before compaction
LSM Block Cache
—
bool
true
Enable block cache
LSM Architecture Overview
[[Svg Src="./witdatabase-lsm-write-flow.svg" Alt="witdatabase-lsm-write-flow"]]
Tuning Guidelines
Scenario
Configuration
Notes
Maximum write throughput
Sync Writes=false;MemTable Size=16777216
Risk: lose recent writes on crash
Balanced (default)
Default settings
Good durability and performance
Memory constrained
MemTable Size=2097152;Block Cache Size=16777216
~18 MB total
Large datasets
MemTable Size=33554432;Block Cache Size=134217728
~160 MB, faster compaction
SSD optimized
LSM Block Size=16384;Sync Writes=false
Larger blocks, async writes
Examples
// High-throughput logging (async writes, large buffers)
"Data Source=/data/logs;Store=lsm;Sync Writes=false;MemTable Size=16777216;Block Cache Size=134217728"
// Memory-constrained environment
"Data Source=/data/app;Store=lsm;MemTable Size=2097152;Block Cache Size=16777216"
// Maximum durability (sync every write)
"Data Source=/data/financial;Store=lsm;Sync Writes=true;LSM WAL=true"
// Disable compaction (manual control)
"Data Source=/data/bulk;Store=lsm;Background Compaction=false"
Durability Warning: Sync Writes=false significantly improves write performance but risks losing the most recent writes (up to MemTable size) on system crash.
Connection Pooling
Connection pooling reuses database connections to reduce overhead in applications with frequent connect/disconnect patterns.
Property
Alias
Type
Default
Description
Pooling
—
bool
false
Enable connection pooling
Min Pool Size
MinPoolSize
int
0
Minimum connections to maintain
Max Pool Size
MaxPoolSize
int
100
Maximum connections allowed
Connection Lifetime
—
int
0
Max connection age in seconds (0 = unlimited)
Idle Timeout
—
int
300
Close idle connections after N seconds
Default Timeout
DefaultTimeout
int
30
Default command timeout in seconds
When to Use Pooling
Scenario
Pooling
Reason
Web API (many short requests)
✅ Yes
Reuse connections across requests
Desktop app (single user)
❌ No
Single long-lived connection is fine
Background service
⚠️ Maybe
Depends on access pattern
Blazor Server
✅ Yes
Many concurrent users
Blazor WASM
❌ No
Single user in browser
Unit tests
❌ No
Fresh connections preferred
Examples
// Basic pooling for web applications
"Data Source=app.witdb;Pooling=true"
// Production web API with tuned pool
"Data Source=app.witdb;Pooling=true;Min Pool Size=5;Max Pool Size=50"
// High-load API server
"Data Source=app.witdb;Pooling=true;Min Pool Size=10;Max Pool Size=200;Connection Lifetime=3600"
// With encryption
"Data Source=secure.witdb;Encryption=aes-gcm;Password=***;Pooling=true;Max Pool Size=50"
Pool Management in Code
// Clear specific pool
WitDbConnection.ClearPool(connectionString);
// Clear all pools
WitDbConnection.ClearAllPools();
Best Practice: In ASP.NET Core, let the DI container manage connection lifetime. Use AddDbContext or AddDbContextPool for EF Core.
Secondary Indexes
Property
Alias
Type
Default
Description
Index Directory
IndexDirectory
string
—
Custom directory for secondary index files
By default, secondary indexes are stored alongside the main database file. Use Index Directory to store them separately (useful for different storage tiers).
// Indexes on fast SSD, data on HDD
"Data Source=/hdd/data.witdb;Index Directory=/ssd/indexes"
Connection String Builder
For programmatic construction, use WitDbConnectionStringBuilder:
using OutWit.Database.AdoNet;
var builder = new WitDbConnectionStringBuilder
{
DataSource = "/var/app/data.witdb",
Store = "btree",
Encryption = "aes-gcm",
Password = Configuration["Database:Password"],
CacheSize = 5000,
IsolationLevel = WitDbIsolationLevel.Snapshot,
Pooling = true,
MaxPoolSize = 50
};
var connectionString = builder.ConnectionString;
// Result: "Data Source=/var/app/data.witdb;Store=btree;Encryption=aes-gcm;Password=***;..."
Parsing Existing Connection String
var builder = new WitDbConnectionStringBuilder(existingConnectionString);
// Read properties
Console.WriteLine(builder.DataSource); // "/var/app/data.witdb"
Console.WriteLine(builder.Encryption); // "aes-gcm"
Console.WriteLine(builder.CacheSize); // 5000
// Modify
builder.CacheSize = 10000;
var newConnectionString = builder.ConnectionString;
Validation
var builder = new WitDbConnectionStringBuilder
{
DataSource = "app.witdb",
Encryption = "aes-gcm"
// Missing Password!
};
// Check for errors
var errors = builder.Validate();
foreach (var error in errors)
{
Console.WriteLine(error); // "Password is required when encryption is enabled."
}
// Or throw exception
builder.ThrowIfInvalid(); // Throws ArgumentException
Builder Properties Reference
Property
Type
Default
Core
DataSource
string
—
Mode
WitDbConnectionMode
ReadWriteCreate
ReadOnly
bool
false
Storage
Store
string
"btree"
Encryption
Encryption
string
—
Password
string
—
User
string
—
FastEncryption
bool
false
Cache
Cache
string
"clock"
CacheSize
int
1000
PageSize
int
4096
Transactions
Transactions
bool
true
Mvcc
bool
true
IsolationLevel
WitDbIsolationLevel
ReadCommitted
Journal
string
"wal"
Concurrency
FileLocking
bool
true
LockTimeout
int
30
ParallelMode
WitDbParallelMode
None
MaxWriters
int
CPU count
Pooling
Pooling
bool
false
MinPoolSize
int
0
MaxPoolSize
int
100
DefaultTimeout
int
30
Index
IndexDirectory
string
—
Enums
WitDbConnectionMode:
public enum WitDbConnectionMode
{
ReadWriteCreate, // Default
ReadWrite,
ReadOnly,
Memory
}
WitDbIsolationLevel:
public enum WitDbIsolationLevel
{
ReadUncommitted,
ReadCommitted, // Default
RepeatableRead,
Serializable,
Snapshot
}
WitDbParallelMode:
public enum WitDbParallelMode
{
None, // Default - single writer
Auto, // Recommended - automatic selection
Buffered, // Buffer writes, batch commit
Latched, // Page-level latching
Optimistic // Optimistic concurrency
}
Complete Properties Reference
All connection string properties in one table:
Core
Property
Type
Default
Description
Data Source
string
required
Path to database or :memory:
Mode
enum
ReadWriteCreate
ReadWriteCreate, ReadWrite, ReadOnly, Memory
Read Only
bool
false
Shortcut for Mode=ReadOnly
Storage Engine
Property
Type
Default
Description
Store
enum
btree
btree, lsm, inmemory
Encryption
Property
Type
Default
Description
Encryption
enum
none
none, aes-gcm, chacha20-poly1305
Password
string
—
Encryption password
User
string
—
Username for key derivation
Fast Encryption
bool
false
Faster PBKDF2 for WASM
Cache
Property
Type
Default
Description
Cache
enum
clock
clock, lru
Cache Size
int
1000
Pages to cache (1–100000)
Page Size
int
4096
Bytes per page (4096–65536)
Transactions
Property
Type
Default
Description
Transactions
bool
true
Enable ACID transactions
MVCC
bool
true
Enable multi-version concurrency
Isolation Level
enum
ReadCommitted
Default isolation level
Journal
enum
wal
wal, rollback
Concurrency
Property
Type
Default
Description
File Locking
bool
true
OS-level file locking
Lock Timeout
int
30
Seconds to wait for lock
Parallel Mode
enum
None
None, Auto, Buffered, Latched, Optimistic
Max Writers
int
CPU count
Concurrent writers (1–64)
Connection Pooling
Property
Type
Default
Description
Pooling
bool
false
Enable pooling
Min Pool Size
int
0
Minimum connections
Max Pool Size
int
100
Maximum connections
Connection Lifetime
int
0
Max age in seconds (0=unlimited)
Idle Timeout
int
300
Close idle after seconds
Default Timeout
int
30
Command timeout
LSM-Tree (only when Store=lsm)
Property
Type
Default
Description
MemTable Size
int
4194304
MemTable bytes (4 MB)
Block Cache Size
int
67108864
Block cache bytes (64 MB)
Sync Writes
bool
true
Sync WAL on write
Background Compaction
bool
true
Auto compaction
LSM WAL
bool
true
Enable WAL
LSM Block Size
int
4096
SSTable block size
LSM Compaction Trigger
int
4
L0 files before compaction
LSM Block Cache
bool
true
Enable block cache
Index
Property
Type
Default
Description
Index Directory
string
—
Custom index storage path