Class NpgsqlDatabaseFacadeExtensions
- Namespace
- Microsoft.EntityFrameworkCore
- Assembly
- Npgsql.EntityFrameworkCore.PostgreSQL.dll
Npgsql specific extension methods for Database.
public static class NpgsqlDatabaseFacadeExtensions
- Inheritance
-
NpgsqlDatabaseFacadeExtensions
- Inherited Members
Methods
IsNpgsql(DatabaseFacade)
Returns true if the database provider currently in use is the Npgsql provider.
This method can only be used after the DbContext has been configured because it is only then that the provider is known. This means that this method cannot be used in OnConfiguring(DbContextOptionsBuilder) because this is where application code sets the provider to use as part of configuring the context.
public static bool IsNpgsql(this DatabaseFacade database)
Parameters
database
DatabaseFacadeThe facade from Database.
Returns
- bool
True if Npgsql is being used; false otherwise.
SetDbDataSource(DatabaseFacade, DbDataSource)
Sets the underlying DbDataSource configured for this DbContext.
public static void SetDbDataSource(this DatabaseFacade databaseFacade, DbDataSource dataSource)
Parameters
databaseFacade
DatabaseFacadeThe DatabaseFacade for the context.
dataSource
DbDataSourceThe connection string.
Remarks
It may not be possible to change the data source if existing connection, if any, is open.
See Connections and connection strings for more information and examples.