Class NpgsqlDbContextOptionsBuilder
Allows for options specific to PostgreSQL to be configured for a
Inheritance
Namespace: Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure
Assembly: Npgsql.EntityFrameworkCore.PostgreSQL.dll
Syntax
public class NpgsqlDbContextOptionsBuilder : RelationalDbContextOptionsBuilder<NpgsqlDbContextOptionsBuilder, NpgsqlOptionsExtension>
Constructors
| Improve this Doc View SourceNpgsqlDbContextOptionsBuilder(DbContextOptionsBuilder)
Initializes a new instance of the NpgsqlDbContextOptionsBuilder class.
Declaration
public NpgsqlDbContextOptionsBuilder(DbContextOptionsBuilder optionsBuilder)
Parameters
Type | Name | Description |
---|---|---|
DbContextOptionsBuilder | optionsBuilder | The core options builder. |
Methods
| Improve this Doc View SourceEnableRetryOnFailure()
Configures the context to use the default retrying
Declaration
public virtual NpgsqlDbContextOptionsBuilder EnableRetryOnFailure()
Returns
Type | Description |
---|---|
NpgsqlDbContextOptionsBuilder | An instance of NpgsqlDbContextOptionsBuilder configured to use
the default retrying |
EnableRetryOnFailure(int, TimeSpan, ICollection<string>?)
Configures the context to use the default retrying
Declaration
public virtual NpgsqlDbContextOptionsBuilder EnableRetryOnFailure(int maxRetryCount, TimeSpan maxRetryDelay, ICollection<string>? errorCodesToAdd)
Parameters
Type | Name | Description |
---|---|---|
int | maxRetryCount | The maximum number of retry attempts. |
TimeSpan | maxRetryDelay | The maximum delay between retries. |
ICollection<><string>? | errorCodesToAdd | Additional error codes that should be considered transient. |
Returns
Type | Description |
---|---|
NpgsqlDbContextOptionsBuilder | An instance of NpgsqlDbContextOptionsBuilder with the specified parameters. |
EnableRetryOnFailure(int)
Configures the context to use the default retrying
Declaration
public virtual NpgsqlDbContextOptionsBuilder EnableRetryOnFailure(int maxRetryCount)
Parameters
Type | Name | Description |
---|---|---|
int | maxRetryCount |
Returns
Type | Description |
---|---|
NpgsqlDbContextOptionsBuilder | An instance of NpgsqlDbContextOptionsBuilder with the specified parameters. |
EnableRetryOnFailure(ICollection<string>?)
Configures the context to use the default retrying
Declaration
public virtual NpgsqlDbContextOptionsBuilder EnableRetryOnFailure(ICollection<string>? errorCodesToAdd)
Parameters
Type | Name | Description |
---|---|---|
ICollection<><string>? | errorCodesToAdd | Additional error codes that should be considered transient. |
Returns
Type | Description |
---|---|
NpgsqlDbContextOptionsBuilder | An instance of NpgsqlDbContextOptionsBuilder with the specified parameters. |
MapRange(string, Type, string?, string?)
Maps a user-defined PostgreSQL range type for use.
Declaration
public virtual NpgsqlDbContextOptionsBuilder MapRange(string rangeName, Type subtypeClrType, string? schemaName = null, string? subtypeName = null)
Parameters
Type | Name | Description |
---|---|---|
string | rangeName | The name of the PostgreSQL range type to be mapped. |
Type | subtypeClrType | The CLR type of the range's subtype (or element).
The actual mapped type will be an |
string? | schemaName | The name of the PostgreSQL schema in which the range is defined. |
string? | subtypeName | Optionally, the name of the range's PostgreSQL subtype (or element).
This is usually not needed - the subtype will be inferred based on |
Returns
Type | Description |
---|---|
NpgsqlDbContextOptionsBuilder |
Examples
To map a range of PostgreSQL real, use the following:
NpgsqlTypeMappingSource.MapRange("floatrange", typeof(float));
|
Improve this Doc
View Source
MapRange<TSubtype>(string, string?, string?)
Maps a user-defined PostgreSQL range type for use.
Declaration
public virtual NpgsqlDbContextOptionsBuilder MapRange<TSubtype>(string rangeName, string? schemaName = null, string? subtypeName = null)
Parameters
Type | Name | Description |
---|---|---|
string | rangeName | The name of the PostgreSQL range type to be mapped. |
string? | schemaName | The name of the PostgreSQL schema in which the range is defined. |
string? | subtypeName | Optionally, the name of the range's PostgreSQL subtype (or element).
This is usually not needed - the subtype will be inferred based on |
Returns
Type | Description |
---|---|
NpgsqlDbContextOptionsBuilder |
Type Parameters
Name | Description |
---|---|
TSubtype | The CLR type of the range's subtype (or element).
The actual mapped type will be an |
Examples
To map a range of PostgreSQL real, use the following:
NpgsqlTypeMappingSource.MapRange{float}("floatrange");
|
Improve this Doc
View Source
ProvideClientCertificatesCallback(ProvideClientCertificatesCallback?)
Configures the
Declaration
public virtual NpgsqlDbContextOptionsBuilder ProvideClientCertificatesCallback(ProvideClientCertificatesCallback? callback)
Parameters
Type | Name | Description |
---|---|---|
ProvideClientCertificatesCallback? | callback | The callback to use. |
Returns
Type | Description |
---|---|
NpgsqlDbContextOptionsBuilder |
ProvidePasswordCallback(ProvidePasswordCallback?)
Configures the
Declaration
public virtual NpgsqlDbContextOptionsBuilder ProvidePasswordCallback(ProvidePasswordCallback? callback)
Parameters
Type | Name | Description |
---|---|---|
ProvidePasswordCallback? | callback | The callback to use. |
Returns
Type | Description |
---|---|
NpgsqlDbContextOptionsBuilder |
RemoteCertificateValidationCallback(RemoteCertificateValidationCallback?)
Configures the
Declaration
public virtual NpgsqlDbContextOptionsBuilder RemoteCertificateValidationCallback(RemoteCertificateValidationCallback? callback)
Parameters
Type | Name | Description |
---|---|---|
RemoteCertificateValidationCallback? | callback | The callback to use. |
Returns
Type | Description |
---|---|
NpgsqlDbContextOptionsBuilder |
SetPostgresVersion(int, int)
Configures the backend version to target.
Declaration
public virtual NpgsqlDbContextOptionsBuilder SetPostgresVersion(int major, int minor)
Parameters
Type | Name | Description |
---|---|---|
int | major | The PostgreSQL major version to target. |
int | minor | The PostgreSQL minor version to target. |
Returns
Type | Description |
---|---|
NpgsqlDbContextOptionsBuilder |
SetPostgresVersion(Version?)
Configures the backend version to target.
Declaration
public virtual NpgsqlDbContextOptionsBuilder SetPostgresVersion(Version? postgresVersion)
Parameters
Type | Name | Description |
---|---|---|
Version? | postgresVersion | The backend version to target. |
Returns
Type | Description |
---|---|
NpgsqlDbContextOptionsBuilder |
UseAdminDatabase(string?)
Connect to this database for administrative operations (creating/dropping databases).
Declaration
public virtual NpgsqlDbContextOptionsBuilder UseAdminDatabase(string? dbName)
Parameters
Type | Name | Description |
---|---|---|
string? | dbName | The name of the database for administrative operations. |
Returns
Type | Description |
---|---|
NpgsqlDbContextOptionsBuilder |
UseRedshift(bool)
Configures the provider to work in Redshift compatibility mode, which avoids certain unsupported features from modern PostgreSQL versions.
Declaration
public virtual NpgsqlDbContextOptionsBuilder UseRedshift(bool useRedshift = true)
Parameters
Type | Name | Description |
---|---|---|
bool | useRedshift | Whether to target Redshift. |
Returns
Type | Description |
---|---|
NpgsqlDbContextOptionsBuilder |