Configuration with MooDbContextOptions
What this page covers#
This page explains the two main settings on MooDbContextOptions.
The options#
MooDbContextOptions currently exposes:
CommandTimeoutSecondsStrictAutoMapping
CommandTimeoutSeconds#
This sets the default command timeout, in seconds, used when a command-specific timeout is not supplied.
The default is 30.
var db = new MooDbContext(connectionString, new MooDbContextOptions { CommandTimeoutSeconds = 60 });
StrictAutoMapping#
This enables stricter validation for MooDb's automatic result mapping.
var db = new MooDbContext(connectionString, new MooDbContextOptions { StrictAutoMapping = true });
When enabled, MooDb validates that the result set and target type line up cleanly before mapping begins.
In strict mode:
- every result column must match a constructor parameter or writable property
- every writable property must be supplied by a constructor parameter or matching result column
- incompatible source and destination member types are rejected early
Strict mapping is not exact type matching. It allows compatible conversions, but prevents mappings that are incomplete, ambiguous, or unsafe.
This can help catch mapping issues early, especially in larger or long-lived systems.