dotConnect for PostgreSQL is a high-performance ORM enabled data provider for PostgreSQL that builds on ADO.NET technology. The provider works with .NET Frameworks 2.0+, .NET Core 2.0+, .NET 5+. It supports a wide range of PostgreSQL-specific features, such as secure SSL and SSH connections, PostgreSQL notifications, PostgreSQL bulk data loading, GEOMETRY, PostgreSQL ARRAY types, and others.a More information at https://www.devart.com/dotconnect/postgresql/ License dotConnect for PostgreSQL is available in several editions https://www.devart.com/dotconnect/postgresql/ordering.html The NuGet package initiates the retrieval of an activation key from the Devart website. This key is required to activate the product for a free trial. Key Features * Easy Connection: Allows your application to work with PostgreSQL. * ASP.NET Core: Supports ASP.NET Core Identity. * Performance: Uses many PostgreSQL-specific performance features & optimizations to ensure the highest performance. * Monitoring: Allows per-component tracing of database events with a free dbMonitor application. * Security: Supports various encryption ciphers, SSL and SSH connections, etc. * Support and updates: Enjoy dedicated support team for prompt issue resolution and regular updates to keep your software running smoothly and securely.
$ dotnet add package Devart.Data.PostgreSql.EFCoredotConnect for PostgreSQL is a high-performance ORM enabled data provider for PostgreSQL that builds on ADO.NET technology.
The provider works with .NET Frameworks 2.0+, .NET Core 2.0+, .NET 5+. The product is compatible with ADO.NET Entity Framework (EF) Core.
It supports a wide range of PostgreSQL-specific features, such as secure SSL and SSH connections, PostgreSQL notifications, PostgreSQL bulk data loading, GEOMETRY, PostgreSQL ARRAY types, and others.
More information at dotConnect for PostgreSQL.
The following table show which version of this package to use with which version of frameworks.
| Frameworks | Version support |
|---|---|
| Entity Framework Core | 10 |
| .NET | 10 |
More information here
For projects, using Entity Framework Core 10 with PostgreSQL, install this package. Execute the following command in the Package Manager Console:
Install-Package Devart.Data.PostgreSql.EFCore
For projects that require integration with Entity Framework 6.4 (EF6), use the Devart.Data.PostgreSql.EF6 package.
There also are Visual Studio extensions for earlier Visual Studio versions. If you use some other tool than Visual Studio, you can get NuGet packages with the nuget.exe console tool.
dotConnect for PostgreSQL is available in several editions. See for ordering.
The NuGet package initiates the retrieval of an activation key from the Devart website. This key is required to activate the product for a free trial.
This snippet directly configures a PostgreSQL database connection for an Entity Framework Core DbContext using a connection string.
public class MyDbContext : DbContext {
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
optionsBuilder.UsePostgreSql(@"UserId=postgres;Password=postgres;Host=127.0.0.1;Port=5432;Database=test;Schema=pg_catalog;");
}
}
Configuration Using PostgreSqlConnection Instance
using Devart.Data.PostgreSql;
...
public class MyDbContext : DbContext {
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
var connection = new PostgreSqlConnection();
connection.Host = "127.0.0.1";
connection.Port = 5432;
connection.UserId = "postgres";
connection.Password = "postgres";
connection.Database = "test";
connection.Schema = "pg_catalog";
optionsBuilder.UsePostgreSql(connection);
}
}
Configuration File (appsettings.json):
{
"ConnectionStrings": {
"DefaultConnection": "UserId=postgres;Password=postgres;Host=127.0.0.1;Port=5432;Database=test;Schema=pg_catalog;"
}
}
DbContext Configuration:
public class MyDbContext : DbContext {
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
IConfigurationBuilder builder = new ConfigurationBuilder().AddJsonFile("appsettings.json");
IConfiguration configuration = builder.Build();
optionsBuilder.UsePostgreSql(configuration.GetConnectionString("DefaultConnection"));
}
}
For more information about secure connections using SSL or SSH connections read at out documentation.