Defaults and collations
Distinguish values from SQL expressions, and comparison intent from a provider's installed collation name.
Examples use Classic and Fluent tabs. Your choice follows you through the manual.
Literal and expression defaults
Ordinary strings are quoted literal values. RawSql.Insert marks trusted SQL to evaluate on the database. The expression below works on SQLite; provider function names and return types can differ.
Classic
Database.AddTable("Events", new Column("CreatedAt", DbType.DateTime)
{
DefaultValue = RawSql.Insert("CURRENT_TIMESTAMP"), IsNullable = false
});Fluent
migration.Create.Table("Events")
.WithColumn("CreatedAt").OfType(DbType.DateTime).NotNullable()
.WithDefaultValue(RawSql.Insert("CURRENT_TIMESTAMP"));Inside Up() / BuildUp(MigrationBuilder migration)
Comparison behavior
Collation presets request semantics. Unsupported mappings fail before DDL. SQLite AsciiIgnoreCase maps to NOCASE and folds ASCII only; it is not Unicode case folding. Named custom SQLite collations must be registered on the connection before schema or data operations use them.
Classic
Database.AddTable("Labels", new Column("Name", DbType.String, 100)
{
Collation = Collation.AsciiIgnoreCase
});Fluent
migration.Create.Table("Labels")
.WithColumn("Name").AsString(100)
.WithCollation(Collation.AsciiIgnoreCase);Inside Up() / BuildUp(MigrationBuilder migration)
Presets and provider names
| Request | Meaning |
|---|---|
| CaseInsensitive / CaseSensitive | Case behavior with accent sensitivity; supported SQL Server/MySQL/MariaDB mappings, or an explicit installed name on other engines. |
| Binary | Provider binary comparison; not a promise of identical linguistic ordering. |
| AsciiIgnoreCase | SQLite NOCASE; ASCII letters only. |
| Collation.Named(name) | An installed or registered provider-specific collation. |
Use named collations for language-specific or exact comparison behavior. PostgreSQL ICU nondeterministic collations must be created explicitly; SQL rendering does not create shared database objects. Read the mapping table for engine versions and restrictions.