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
csharp
// 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"
// 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).
csharp
// Good: from environmentvar password = Environment.GetEnvironmentVariable("DB_PASSWORD");
$"Data Source=app.witdb;Encryption=aes-gcm;Password={password}"// Good: from configurationvar 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
csharp
// 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"
Warning: Only disable file locking if you guarantee single-process access. Multiple processes without locking will corrupt the database.
Common Scenarios
Development / Testing
csharp
// Simple file database"Data Source=dev.witdb"// In-memory for unit tests"Data Source=:memory:"
Web Application (ASP.NET Core)
csharp
// With encryption and connection pooling"Data Source=/var/app/data.witdb;Encryption=aes-gcm;Password=***;Pooling=true;Max Pool Size=50;Isolation Level=Snapshot"
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
csharp
// 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
csharp
// 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).
csharp
// Indexes on fast SSD, data on HDD"Data Source=/hdd/data.witdb;Index Directory=/ssd/indexes"
Connection String Builder
For programmatic construction, use WitDbConnectionStringBuilder:
csharp
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
csharp
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
csharp
var builder = new WitDbConnectionStringBuilder
{
DataSource = "app.witdb",
Encryption = "aes-gcm"// Missing Password!
};
// Check for errorsvar 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