Skip to content

Configuration Options

okramarenko edited this page Jun 25, 2025 · 2 revisions

Configuration Options

For a general sample how to call UseSingleStore(), see Services Configuration.

Mandatory parameters

Connection String

Provide a connection string for the database you want to connect to.

We use SingleStoreConnector underneath for all communication between SingleStore.EntityFrameworkCore and SingleStoreDB. For a complete list of all connection string options, see SingleStoreConnector Connection String Options.

Optional settings

The following settings can be used on demand, by calling their respective extension method in the UseSingleStore() call.

EnableRetryOnFailure

Configures the context to use the default retrying IExecutionStrategy.

DisableBackslashEscaping

Configures string escaping in SQL query generation to ignore backslashes, and assumes that sql_mode has been set to NO_BACKSLASH_ESCAPES. This applies to both constant and parameter values (i. e. user input, potentially).

SetSqlModeOnOpen

When true, implicitly executes a SET SESSION sql_mode statement after opening a connection to the database server, adding the modes enabled by other options. When false, the sql_mode is not being set by the provider and has to be manually handled by the caller, to synchronize it with other options that have been set.

DisableLineBreakToCharSubstition

Skip replacing \r and \n with CHAR() calls in strings inside queries.

DefaultDataTypeMappings

Configures default mappings between specific CLR and SingleStoreDB types.

  • WithClrBoolean
    • Default (same as TinyInt1)
    • TinyInt1
    • Bit1
  • WithClrDateTime and WithClrDateTimeOffset
    • Default (highest DATETIME precision supported by the current database server)
    • DateTime
    • DateTime6
    • Timestamp
    • Timestamp6
  • WithClrTimeSpan
    • Default (highest TIME precision supported by the current database server)
    • Time
    • Time6

SchemaBehavior

Configures the behavior for cases when a schema has been set for an entity. Because SingleStoreDB does not support the EF Core concept of schemas, the default is to throw an exception.

EnableIndexOptimizedBooleanColumns

Configures the context to optimize System.Boolean mapped columns for index usage, by translating e.BoolColumn to BoolColumn = TRUE and !e.BoolColumn to BoolColumn = FALSE.

LimitKeyedOrIndexedStringColumnLength

Configures the context to automatically limit the length of System.String mapped columns, that have not explicitly mapped to a store type (e.g. varchar(1024)), to ensure that at least two indexed columns will be allowed on a given table (this is the default if you don't configure this option). If you intend to use HasPrefixLength() for those kind of columns, set this option to false.

EnableStringComparisonTranslations

Configures the context to translate string related methods, containing a parameter of type StringComparison, to their SQL equivalent, even though SingleStoreDB might not be able to use indexes when executing the query, resulting in decreased performance. Whether SingleStoreDB is able to use indexes for the query, depends on the StringComparison option, the underlying collation and the scenario. It is also possible to just use EF.Functions.Collate(), possibly in addition to string.ToUpper() if needed, to achieve the same result but with full control over the SQL generation.