# TraconPostgreSqlOptions

> 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.traconpostgresqloptions/
> Summary: TraconPostgreSqlOptions: Settings for Tracon's PostgreSQL persistence layer.

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

Settings for Tracon's PostgreSQL persistence layer.

```csharp
public sealed class TraconPostgreSqlOptions
```

<dl class="api-relations"><dt>Inheritance</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object">object</a> ← <a href="/api/tracon.traconpostgresqloptions/">TraconPostgreSqlOptions</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.TraconPostgreSqlOptionsValidator](/api/tracon/);
`DataAnnotations` is not used.

## Constructors

### <a id="Tracon_TraconPostgreSqlOptions__ctor"></a> TraconPostgreSqlOptions\(\)

```csharp
public TraconPostgreSqlOptions()
```

## Fields

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

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

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

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

### <a id="Tracon_TraconPostgreSqlOptions_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_TraconPostgreSqlOptions_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_TraconPostgreSqlOptions_ConnectionString"></a> ConnectionString

The PostgreSQL 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 [TraconPostgreSqlOptions.DataSource](/api/tracon.traconpostgresqloptions/#Tracon_TraconPostgreSqlOptions_DataSource) is set; giving both is an error.

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

The data source Tracon uses, instead of building its own from
[TraconPostgreSqlOptions.ConnectionString](/api/tracon.traconpostgresqloptions/#Tracon_TraconPostgreSqlOptions_ConnectionString).

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

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

Must be an `NpgsqlDataSource` (built with `NpgsqlDataSourceBuilder`)
— for example, the same instance an EF Core `DbContext` was configured
with via `UseNpgsql(dataSource)`. When set, [TraconPostgreSqlOptions.ConnectionString](/api/tracon.traconpostgresqloptions/#Tracon_TraconPostgreSqlOptions_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.

```csharp
var dataSource = new Npgsql.NpgsqlDataSourceBuilder(connectionString).Build();

// Also give the same instance to your own EF Core DbContext
// (o => o.UseNpgsql(dataSource)) to share one connection pool.
builder.AddTracon()
       .UsePostgreSql(o => o.DataSource = dataSource);
```

### <a id="Tracon_TraconPostgreSqlOptions_EnableKnowledge"></a> EnableKnowledge

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

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

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

The knowledge set needs the `pgvector` extension; a
consumer on a managed PostgreSQL without permission to install
extensions never sees it unless this is turned on. While it is
[false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool), no [IVectorSearchStore](/api/tracon.ivectorsearchstore/) is
registered — an agent definition that requests vector search fails
compilation with a clear error instead of a database error at run
time.

### <a id="Tracon_TraconPostgreSqlOptions_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_TraconPostgreSqlOptions_SchemaName"></a> SchemaName

The schema Tracon's tables are created in. The consumer's `public`
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

Must follow the rules for an unquoted PostgreSQL identifier: starts with a
lowercase letter or underscore, contains lowercase letters, digits, and
underscores, at most 63 characters.
