# TraconSqlServerOptions

> Tracon documentation. Tracon is a .NET package family that adds a control
> plane on Microsoft Agent Framework, published as NuGet packages that run
> inside your own ASP.NET Core application.
>
> Page: https://tracon.dev/api/tracon.traconsqlserveroptions/
> Summary: TraconSqlServerOptions: Settings for Tracon's SQL Server persistence layer.

<div class="api-provenance">Namespace Tracon · Assembly <code>Tracon.SqlServer.dll</code></div>

Settings for Tracon's SQL Server persistence layer.

```csharp
public sealed class TraconSqlServerOptions
```

<dl class="api-relations"><dt>Inheritance</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object">object</a> ← <a href="/api/tracon.traconsqlserveroptions/">TraconSqlServerOptions</a></dd><dt>Inherited Members</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a></dd></dl>

## Remarks

Validation is done by hand in [Tracon.TraconSqlServerOptionsValidator](/api/tracon/);
`DataAnnotations` is not used.

## Constructors

### <a id="Tracon_TraconSqlServerOptions__ctor"></a> TraconSqlServerOptions\(\)

```csharp
public TraconSqlServerOptions()
```

## Fields

### <a id="Tracon_TraconSqlServerOptions_SectionName"></a> SectionName

The full path of the configuration section settings are read from.

```csharp
public const string SectionName = "Tracon:SqlServer"
```

#### Field Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

## Properties

### <a id="Tracon_TraconSqlServerOptions_AutoApplyMigrations"></a> AutoApplyMigrations

Whether pending migrations are applied automatically at application startup.

```csharp
public bool AutoApplyMigrations { get; set; }
```

#### Property Value

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

#### Remarks

Can be set to [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) in production, with migrations applied
as a separate deployment step - the `tracon migrate` command, or
[IMigrationApplier.ApplyAsync](/api/tracon.imigrationapplier/#Tracon_IMigrationApplier_ApplyAsync_System_Threading_CancellationToken_) - so a long-running migration
does not block application startup.

### <a id="Tracon_TraconSqlServerOptions_CommandTimeoutSeconds"></a> CommandTimeoutSeconds

The upper time limit for a single SQL command (seconds). 0 means unlimited.

```csharp
public int CommandTimeoutSeconds { get; set; }
```

#### Property Value

 [int](https://learn.microsoft.com/dotnet/api/system.int32)

### <a id="Tracon_TraconSqlServerOptions_ConnectionString"></a> ConnectionString

The SQL Server connection string.

```csharp
public string? ConnectionString { get; set; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)?

#### Remarks

**This value is a secret and is never written to a file.** Use
`dotnet user-secrets`, an environment variable, or a secret manager.
Not required when [TraconSqlServerOptions.DataSource](/api/tracon.traconsqlserveroptions/#Tracon_TraconSqlServerOptions_DataSource) is set; giving both is an error.

### <a id="Tracon_TraconSqlServerOptions_DataSource"></a> DataSource

The data source Tracon uses, instead of building its own from
[TraconSqlServerOptions.ConnectionString](/api/tracon.traconsqlserveroptions/#Tracon_TraconSqlServerOptions_ConnectionString).

```csharp
public DbDataSource? DataSource { get; set; }
```

#### Property Value

 [DbDataSource](https://learn.microsoft.com/dotnet/api/system.data.common.dbdatasource)?

#### Remarks

`Microsoft.Data.SqlClient` does not itself offer a [DbDataSource](https://learn.microsoft.com/dotnet/api/system.data.common.dbdatasource)
implementation (measured against version 7.1.1); give an adapter of your
own if you need to share a connection pool with another consumer of the
same database. When set, [TraconSqlServerOptions.ConnectionString](/api/tracon.traconsqlserveroptions/#Tracon_TraconSqlServerOptions_ConnectionString) is not required,
and giving both is a startup error.

Tracon does **not** take ownership: the instance is never
disposed. The caller keeps ownership and disposes it when the host shuts
down.

### <a id="Tracon_TraconSqlServerOptions_EnableReadViews"></a> EnableReadViews

Whether the "views" migration set is applied. Default [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool).

```csharp
public bool EnableReadViews { get; set; }
```

#### Property Value

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

#### Remarks

Creates `{schema}.runs_v1`, a versioned, read-only, narrow view a
consumer can query directly (for example from an EF Core keyless
entity) without depending on the internal `runs` table shape.
Off by default: a consumer that never opts in pays nothing for it.

### <a id="Tracon_TraconSqlServerOptions_SchemaName"></a> SchemaName

The schema Tracon's tables are created in. The consumer's `dbo`
schema is never touched, under any circumstances.

```csharp
public string SchemaName { get; set; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

#### Remarks

Even though SQL Server allows a wider set of identifiers, Tracon
enforces the *same strict rule*: starts with a lowercase letter
or underscore, contains lowercase letters, digits, and underscores, at
most 63 characters. This way the same schema name carries over between
PostgreSQL and SQL Server without changes.
