Class NpgsqlDbContextOptionsBuilderExtensions
- Namespace
- Microsoft.EntityFrameworkCore
- Assembly
- Npgsql.EntityFrameworkCore.PostgreSQL.dll
Provides extension methods on DbContextOptionsBuilder and DbContextOptionsBuilder<TContext> used to configure a DbContext to context to a PostgreSQL database with Npgsql.
public static class NpgsqlDbContextOptionsBuilderExtensions
- Inheritance
-
NpgsqlDbContextOptionsBuilderExtensions
- Inherited Members
Methods
UseNpgsql(DbContextOptionsBuilder, Action<NpgsqlDbContextOptionsBuilder>?)
Configures the context to connect to a PostgreSQL server with Npgsql, but without initially setting any DbConnection or connection string.
The connection or connection string must be set before the DbContext is used to connect to a database. Set a connection using SetDbConnection(DatabaseFacade, DbConnection, bool). Set a connection string using SetConnectionString(DatabaseFacade, string).
public static DbContextOptionsBuilder UseNpgsql(this DbContextOptionsBuilder optionsBuilder, Action<NpgsqlDbContextOptionsBuilder>? npgsqlOptionsAction = null)
Parameters
optionsBuilderDbContextOptionsBuilderThe builder being used to configure the context.
npgsqlOptionsActionAction<NpgsqlDbContextOptionsBuilder>An optional action to allow additional Npgsql-specific configuration.
Returns
- DbContextOptionsBuilder
The options builder so that further configuration can be chained.
UseNpgsql(DbContextOptionsBuilder, DbConnection, Action<NpgsqlDbContextOptionsBuilder>?)
Configures the context to connect to a PostgreSQL database with Npgsql.
public static DbContextOptionsBuilder UseNpgsql(this DbContextOptionsBuilder optionsBuilder, DbConnection connection, Action<NpgsqlDbContextOptionsBuilder>? npgsqlOptionsAction = null)
Parameters
optionsBuilderDbContextOptionsBuilderThe builder being used to configure the context.
connectionDbConnectionAn existing DbConnection to be used to connect to the database. If the connection is in the open state then EF will not open or close the connection. If the connection is in the closed state then EF will open and close the connection as needed. The caller owns the connection and is responsible for its disposal.
npgsqlOptionsActionAction<NpgsqlDbContextOptionsBuilder>An optional action to allow additional Npgsql-specific configuration.
Returns
- DbContextOptionsBuilder
The options builder so that further configuration can be chained.
UseNpgsql(DbContextOptionsBuilder, DbConnection, bool, Action<NpgsqlDbContextOptionsBuilder>?)
Configures the context to connect to a PostgreSQL database with Npgsql.
public static DbContextOptionsBuilder UseNpgsql(this DbContextOptionsBuilder optionsBuilder, DbConnection connection, bool contextOwnsConnection, Action<NpgsqlDbContextOptionsBuilder>? npgsqlOptionsAction = null)
Parameters
optionsBuilderDbContextOptionsBuilderA builder for setting options on the context.
connectionDbConnectionAn existing DbConnection to be used to connect to the database. If the connection is in the open state then EF will not open or close the connection. If the connection is in the closed state then EF will open and close the connection as needed.
contextOwnsConnectionboolIf true, then EF will take ownership of the connection and will dispose it in the same way it would dispose a connection created by EF. If false, then the caller still owns the connection and is responsible for its disposal.
npgsqlOptionsActionAction<NpgsqlDbContextOptionsBuilder>An optional action to allow additional Npgsql-specific configuration.
Returns
- DbContextOptionsBuilder
The options builder so that further configuration can be chained.
UseNpgsql(DbContextOptionsBuilder, DbDataSource, Action<NpgsqlDbContextOptionsBuilder>?)
Configures the context to connect to a PostgreSQL database with Npgsql.
public static DbContextOptionsBuilder UseNpgsql(this DbContextOptionsBuilder optionsBuilder, DbDataSource dataSource, Action<NpgsqlDbContextOptionsBuilder>? npgsqlOptionsAction = null)
Parameters
optionsBuilderDbContextOptionsBuilderA builder for setting options on the context.
dataSourceDbDataSourceA DbDataSource which will be used to get database connections.
npgsqlOptionsActionAction<NpgsqlDbContextOptionsBuilder>An optional action to allow additional Npgsql-specific configuration.
Returns
- DbContextOptionsBuilder
The options builder so that further configuration can be chained.
UseNpgsql(DbContextOptionsBuilder, string?, Action<NpgsqlDbContextOptionsBuilder>?)
Configures the context to connect to a PostgreSQL database with Npgsql.
public static DbContextOptionsBuilder UseNpgsql(this DbContextOptionsBuilder optionsBuilder, string? connectionString, Action<NpgsqlDbContextOptionsBuilder>? npgsqlOptionsAction = null)
Parameters
optionsBuilderDbContextOptionsBuilderA builder for setting options on the context.
connectionStringstringThe connection string of the database to connect to.
npgsqlOptionsActionAction<NpgsqlDbContextOptionsBuilder>An optional action to allow additional Npgsql-specific configuration.
Returns
- DbContextOptionsBuilder
The options builder so that further configuration can be chained.
UseNpgsql<TContext>(DbContextOptionsBuilder<TContext>, Action<NpgsqlDbContextOptionsBuilder>?)
Configures the context to connect to a PostgreSQL server with Npgsql, but without initially setting any DbConnection, DbDataSource or connection string.
The connection, data source or connection string must be set explicitly or registered in the DI before the DbContext is used to connect to a database. Set a connection using SetDbConnection(DatabaseFacade, DbConnection, bool), a data source using SetDbDataSource(DatabaseFacade, DbDataSource), or a connection string using SetConnectionString(DatabaseFacade, string).
public static DbContextOptionsBuilder<TContext> UseNpgsql<TContext>(this DbContextOptionsBuilder<TContext> optionsBuilder, Action<NpgsqlDbContextOptionsBuilder>? npgsqlOptionsAction = null) where TContext : DbContext
Parameters
optionsBuilderDbContextOptionsBuilder<TContext>The builder being used to configure the context.
npgsqlOptionsActionAction<NpgsqlDbContextOptionsBuilder>An optional action to allow additional Npgsql-specific configuration.
Returns
- DbContextOptionsBuilder<TContext>
The options builder so that further configuration can be chained.
Type Parameters
TContext
UseNpgsql<TContext>(DbContextOptionsBuilder<TContext>, DbConnection, Action<NpgsqlDbContextOptionsBuilder>?)
Configures the context to connect to a PostgreSQL database with Npgsql.
public static DbContextOptionsBuilder<TContext> UseNpgsql<TContext>(this DbContextOptionsBuilder<TContext> optionsBuilder, DbConnection connection, Action<NpgsqlDbContextOptionsBuilder>? npgsqlOptionsAction = null) where TContext : DbContext
Parameters
optionsBuilderDbContextOptionsBuilder<TContext>A builder for setting options on the context.
connectionDbConnectionAn existing DbConnection to be used to connect to the database. If the connection is in the open state then EF will not open or close the connection. If the connection is in the closed state then EF will open and close the connection as needed. The caller owns the connection and is responsible for its disposal.
npgsqlOptionsActionAction<NpgsqlDbContextOptionsBuilder>An optional action to allow additional Npgsql-specific configuration.
Returns
- DbContextOptionsBuilder<TContext>
The options builder so that further configuration can be chained.
Type Parameters
TContext
UseNpgsql<TContext>(DbContextOptionsBuilder<TContext>, DbConnection, bool, Action<NpgsqlDbContextOptionsBuilder>?)
Configures the context to connect to a PostgreSQL database with Npgsql.
public static DbContextOptionsBuilder<TContext> UseNpgsql<TContext>(this DbContextOptionsBuilder<TContext> optionsBuilder, DbConnection connection, bool contextOwnsConnection, Action<NpgsqlDbContextOptionsBuilder>? npgsqlOptionsAction = null) where TContext : DbContext
Parameters
optionsBuilderDbContextOptionsBuilder<TContext>The builder being used to configure the context.
connectionDbConnectionAn existing DbConnection to be used to connect to the database. If the connection is in the open state then EF will not open or close the connection. If the connection is in the closed state then EF will open and close the connection as needed.
contextOwnsConnectionboolIf true, then EF will take ownership of the connection and will dispose it in the same way it would dispose a connection created by EF. If false, then the caller still owns the connection and is responsible for its disposal.
npgsqlOptionsActionAction<NpgsqlDbContextOptionsBuilder>An optional action to allow additional Npgsql-specific configuration.
Returns
- DbContextOptionsBuilder<TContext>
The options builder so that further configuration can be chained.
Type Parameters
TContextThe type of context to be configured.
UseNpgsql<TContext>(DbContextOptionsBuilder<TContext>, DbDataSource, Action<NpgsqlDbContextOptionsBuilder>?)
Configures the context to connect to a PostgreSQL database with Npgsql.
public static DbContextOptionsBuilder<TContext> UseNpgsql<TContext>(this DbContextOptionsBuilder<TContext> optionsBuilder, DbDataSource dataSource, Action<NpgsqlDbContextOptionsBuilder>? npgsqlOptionsAction = null) where TContext : DbContext
Parameters
optionsBuilderDbContextOptionsBuilder<TContext>A builder for setting options on the context.
dataSourceDbDataSourceA DbDataSource which will be used to get database connections.
npgsqlOptionsActionAction<NpgsqlDbContextOptionsBuilder>An optional action to allow additional Npgsql-specific configuration.
Returns
- DbContextOptionsBuilder<TContext>
The options builder so that further configuration can be chained.
Type Parameters
TContext
UseNpgsql<TContext>(DbContextOptionsBuilder<TContext>, string?, Action<NpgsqlDbContextOptionsBuilder>?)
Configures the context to connect to a PostgreSQL database with Npgsql.
public static DbContextOptionsBuilder<TContext> UseNpgsql<TContext>(this DbContextOptionsBuilder<TContext> optionsBuilder, string? connectionString, Action<NpgsqlDbContextOptionsBuilder>? npgsqlOptionsAction = null) where TContext : DbContext
Parameters
optionsBuilderDbContextOptionsBuilder<TContext>A builder for setting options on the context.
connectionStringstringThe connection string of the database to connect to.
npgsqlOptionsActionAction<NpgsqlDbContextOptionsBuilder>An optional action to allow additional Npgsql-configuration.
Returns
- DbContextOptionsBuilder<TContext>
The options builder so that further configuration can be chained.
Type Parameters
TContext