Search Results for

    Show / Hide Table of Contents

    Class NpgsqlDbContextOptionsBuilder

    Allows for options specific to PostgreSQL to be configured for a .

    Inheritance
    Object
    NpgsqlDbContextOptionsBuilder
    Namespace: Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure
    Assembly: Npgsql.EntityFrameworkCore.PostgreSQL.dll
    Syntax
    public class NpgsqlDbContextOptionsBuilder : RelationalDbContextOptionsBuilder<NpgsqlDbContextOptionsBuilder, NpgsqlOptionsExtension>

    Constructors

    | Improve this Doc View Source

    NpgsqlDbContextOptionsBuilder(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 Source

    EnableRetryOnFailure()

    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 .

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    EnableRetryOnFailure(Int32, 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
    Int32 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.

    | Improve this Doc View Source

    EnableRetryOnFailure(Int32)

    Configures the context to use the default retrying .

    Declaration
    public virtual NpgsqlDbContextOptionsBuilder EnableRetryOnFailure(int maxRetryCount)
    Parameters
    Type Name Description
    Int32 maxRetryCount
    Returns
    Type Description
    NpgsqlDbContextOptionsBuilder

    An instance of NpgsqlDbContextOptionsBuilder with the specified parameters.

    | Improve this Doc View Source

    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 over this type.

    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 subtypeClrType.

    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 TSubtype.

    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 over this type.

    Examples

    To map a range of PostgreSQL real, use the following:

    NpgsqlTypeMappingSource.MapRange{float}("floatrange");
    | Improve this Doc View Source

    ProvideClientCertificatesCallback(Nullable<ProvideClientCertificatesCallback>)

    Configures the to use the specified ProvideClientCertificatesCallback(Nullable<ProvideClientCertificatesCallback>).

    Declaration
    public virtual NpgsqlDbContextOptionsBuilder ProvideClientCertificatesCallback(ProvideClientCertificatesCallback? callback)
    Parameters
    Type Name Description
    Nullable<ProvideClientCertificatesCallback> callback

    The callback to use.

    Returns
    Type Description
    NpgsqlDbContextOptionsBuilder
    | Improve this Doc View Source

    ProvidePasswordCallback(Nullable<ProvidePasswordCallback>)

    Configures the to use the specified ProvidePasswordCallback(Nullable<ProvidePasswordCallback>).

    Declaration
    public virtual NpgsqlDbContextOptionsBuilder ProvidePasswordCallback(ProvidePasswordCallback? callback)
    Parameters
    Type Name Description
    Nullable<ProvidePasswordCallback> callback

    The callback to use.

    Returns
    Type Description
    NpgsqlDbContextOptionsBuilder
    | Improve this Doc View Source

    RemoteCertificateValidationCallback(RemoteCertificateValidationCallback)

    Configures the to use the specified RemoteCertificateValidationCallback(RemoteCertificateValidationCallback).

    Declaration
    public virtual NpgsqlDbContextOptionsBuilder RemoteCertificateValidationCallback(RemoteCertificateValidationCallback callback)
    Parameters
    Type Name Description
    RemoteCertificateValidationCallback callback

    The callback to use.

    Returns
    Type Description
    NpgsqlDbContextOptionsBuilder
    | Improve this Doc View Source

    SetPostgresVersion(Int32, Int32)

    Configures the backend version to target.

    Declaration
    public virtual NpgsqlDbContextOptionsBuilder SetPostgresVersion(int major, int minor)
    Parameters
    Type Name Description
    Int32 major

    The PostgreSQL major version to target.

    Int32 minor

    The PostgreSQL minor version to target.

    Returns
    Type Description
    NpgsqlDbContextOptionsBuilder
    | Improve this Doc View Source

    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
    | Improve this Doc View Source

    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
    | Improve this Doc View Source

    UseRedshift(Boolean)

    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
    Boolean useRedshift

    Whether to target Redshift.

    Returns
    Type Description
    NpgsqlDbContextOptionsBuilder

    Extension Methods

    NpgsqlNetTopologySuiteDbContextOptionsBuilderExtensions.UseNetTopologySuite(NpgsqlDbContextOptionsBuilder, Nullable<CoordinateSequenceFactory>, Nullable<PrecisionModel>, Ordinates, Boolean)
    NpgsqlNodaTimeDbContextOptionsBuilderExtensions.UseNodaTime(NpgsqlDbContextOptionsBuilder)
    • Improve this Doc
    • View Source
    In This Article
    Back to top © Copyright 2022 The Npgsql Development Team