ISM.Database.PostgreSQL 1.0.5

I.S.M. Database PostgreSQL

🏷️ Introduction

This package provides a PostgreSQL database configuration for the I.S.M. Database library. It allows you to easily set up and manage your PostgreSQL database connections, including support for retry logic on transient errors in production environments.

🛠️ Configuration

To configure the database connection, you can use the following connection string format in your application's configuration file (e.g., appsettings.json):

{
  "ConnectionStrings": {
    "SqlConnection": "Host=[HOSTNAME];Port=5432;Database=IdentityManager;Username=[USERNAME];Password=[PASSWORD];Include Error Detail=true"
  }
}

[!TIP] The list of additional SQL error numbers to consider transient can be used to specify any custom error codes that your application may encounter and want to treat as transient errors for retry logic.

And to configure PostgreSQL specific settings, you can add the following section to your configuration file:

{
  "PostgreSQLSettings": {
    "MigrationAssembly": "YourProject.Migrations",
    "Environment": "Development", // or "Staging" or "Production"
    "PostgresVersionMajority": 13, // PostgreSQL 13
    "PostgresVersionMinority": 0, // PostgreSQL 13.0

    // The settings below are used for retry logic on transient errors in production environment only.
    "CommandTimeout": 180, // in seconds
    "MaxRetryCount": 5, // number of retry attempts for transient failures
    "MaxRetryDelay": "00:00:10", // maximum delay between retries (10 seconds)
    "ErrorNumbersToAdd": [] // list of additional SQL error numbers to consider transient
  }
}

[!NOTE] The list is available in this PostgreSQL documentation and can be used to enhance the robustness of your application's database interactions by allowing you to specify additional error codes that should trigger retry logic.

In your application's startup code (e.g., Program.cs), you can retrieve the connection string and PostgreSQL settings from the configuration and create the PostgreSQL configuration object as follows:

var connectionString = builder.Configuration.GetConnectionString("SqlConnection")!;
var postgreSQLSettings = builder.Services.ConfigureAndGet<PostgreSQLSettings>(builder.Configuration, nameof(PostgreSQLSettings));

var postgreSQLConfiguration = GetPostgreSQLConfiguration(builder, connectionString, postgreSQLSettings);

Finally in the DbContext configuration it is necessary to add the relevant configuration.

builder.Services.AddDbContext<YourDbContext>(options =>
{
    options.UsePostgreSQLConfiguration(postgreSQLConfiguration);
});

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.

No packages depend on ISM.Database.PostgreSQL.

Version Downloads Last updated
1.0.6 0 07/05/2026
1.0.5 0 06/15/2026
1.0.3 0 06/04/2026
1.0.2 0 05/27/2026