Skip to content

Configuration

Martin Costello edited this page Mar 8, 2015 · 16 revisions

Configuration Settings

Introduction

This wiki page documents the configuration settings available for the System.Data.SqlLocalDb.dll assembly.

As well as a custom configuration section that can be included in the application configuration file, two legacy appSettings values that existed in versions of the assembly prior to v1.13.0.0 are still supported for backwards compatibility.

Note: New settings are documented as they are added, so may not be available in the current released version. Where this is the case, it is noted in the relevant section.

Default Configuration

An example of an application configuration file containing the custom configuration section with all the values configured to their default values is shown below.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="system.data.sqlLocalDb" type="System.Data.SqlLocalDb.Configuration.SqlLocalDbConfigurationSection, System.Data.SqlLocalDb" />
  </configSections>
  <system.data.sqlLocalDb
    automaticallyDeleteInstanceFiles="false"
    language=""
    loggerType=""
    overrideVersion=""
    stopOptions="None"
    stopTimeout="00:01:00"
    />
</configuration>

system.data.sqlLocalDb Configuration Section

The configuration attributes of the custom system.data.sqlLocalDb configuration section are documented below. If the custom configuration section is not defined or present in the application configuration file, the default values documented below (and shown in the configuration file example above) are used.

automaticallyDeleteInstanceFiles

Type: bool

Default: false

Specifies whether to automatically delete the files associated with SQL LocalDB instances when they are deleted. The default behavior is to leave these files on disk as this is the default behavior of the SQL LocalDB Instance API.

Enabling this setting will cause the assembly to delete all files stored in %LOCALAPPDATA%\Microsoft\Microsoft SQL Server Local DB\Instances that are associated with the SQL LocalDB instance being deleted.

The setting controls the default value of the System.Data.SqlLocalDb.SqlLocalDbApi.AutomaticallyDeleteInstanceFiles property.

language

Type: string

Default: ""

A culture name that overrides the default behavior of the SQL LocalDB Instance API, which formats error messages according to the language and locale settings of the locally installed operating system, to instead use the Locale ID (LCID) associated with the specified value. Any value that can be parsed to create a .NET CultureInfo instance is supported, but standard culture codes are recommended (e.g. en-US, fr-FR etc.).

Available from v1.14.0

loggerType

Type: Type

Default: null

The type of the implementation of System.Data.SqlLocalDb.ILogger to use for logging by the assembly. The type specified must meet the following criteria:

  1. Must implement the System.Data.SqlLocalDb.ILogger interface;
  2. Must have a parameter-less default constructor. The constructor can be internal.

There is an example implementation of an ILogger that uses log4net in the TestApp project.

Available from v1.14.0

overrideVersion

Type: string

Default: ""

The override version string of the native SQL LocalDB API to load, if any. The default behavior is to always load the latest version of the SQL Server LocalDB API installed on the local computer.

As the SQL LocalDB Instance API native DLL is loaded into the process' memory when first used and is not unloaded again until the process terminates this setting can only be controlled through the application configuration file.

stopOptions

Type: System.Data.SqlLocalDb.StopInstanceOptions

Default: StopInstanceOptions.None

The options to use when stopping instances of SQL LocalDB.

The StopInstanceOptions enumeration specified the [System.Flags] attribute, so the values can be combined by specifying multiple values separated by a comma ',', for example: stopOptions="KillProcess, NoWait".

Supported values are:

  • StopInstanceOptions.KillProcess (maps to the LOCALDB_SHUTDOWN_KILL_PROCESS flag in the native API).
  • StopInstanceOptions.NoWait (maps to the LOCALDB_SHUTDOWN_WITH_NOWAIT flag in the native API).

The setting controls the default value of the System.Data.SqlLocalDb.SqlLocalDbApi.StopOptions property.

stopTimeout

Type: System.TimeSpan

Default: 00:01:00 (1 minute)

The default timeout used to wait for SQL LocalDB instances to stop. Whilst this setting is a TimeSpan, the resolution of the value is only used to a granularity of seconds.

The setting controls the default value of the System.Data.SqlLocalDb.SqlLocalDbApi.StopTimeout property.

Legacy Application Settings

The two legacy application configuration settings that are supported for backwards compatibility are documented below.

These settings are honored if the setting that supersedes it in the system.data.sqlLocalDb custom configuration section has not been explicitly set.

SQLLocalDB:AutomaticallyDeleteInstanceFiles

This setting has been superseded by the /configuration/system.data.sqlLocalDb/@automaticallyDeleteInstanceFiles configuration attribute.

SQLLocalDB:OverrideVersion

This setting has been superseded by the /configuration/system.data.sqlLocalDb/@overrideVersion configuration attribute.

NuGet

Clone this wiki locally