Webion.Extensions.Configuration.Npgsql 1.1.2

dotnet add package Webion.Extensions.Configuration.Npgsql --version 1.1.2
                    
NuGet\Install-Package Webion.Extensions.Configuration.Npgsql -Version 1.1.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Webion.Extensions.Configuration.Npgsql" Version="1.1.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Webion.Extensions.Configuration.Npgsql" Version="1.1.2" />
                    
Directory.Packages.props
<PackageReference Include="Webion.Extensions.Configuration.Npgsql" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Webion.Extensions.Configuration.Npgsql --version 1.1.2
                    
#r "nuget: Webion.Extensions.Configuration.Npgsql, 1.1.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Webion.Extensions.Configuration.Npgsql@1.1.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Webion.Extensions.Configuration.Npgsql&version=1.1.2
                    
Install as a Cake Addin
#tool nuget:?package=Webion.Extensions.Configuration.Npgsql&version=1.1.2
                    
Install as a Cake Tool

Webion.Extensions.Configuration.Npgsql

The Webion.Extensions.Configuration.Npgsql library provides an implementation for integrating PostgreSQL as a configuration provider in .NET applications using the IConfigurationBuilder mechanism.

Features

  • Load configuration values directly from a PostgreSQL database.
  • Filter configuration values by environment.
  • Customize schema and table names for storing configuration data.
  • Seamless integration with Microsoft.Extensions.Configuration.

Installation

To include this library in your project, you can add it via NuGet:

dotnet add package Webion.Extensions.Configuration.Npgsql --version 1.1

Or update your .csproj file:

<PackageReference Include="Webion.Extensions.Configuration.Npgsql" Version="1.1" />

Usage

Below is an example of how to use the AddNpgsql extension method to configure your application to load settings from a PostgreSQL database:

var builder = new ConfigurationBuilder();

builder.Configuration.AddNpgsql(
    connectionString: $"Host={host};Port={port};User={user};Password={password}",
    environment: builder.Environment.EnvironmentName,
    schemaName: "public",
    tableName: "app_setting"
);

Configuration Table Structure

The PostgreSQL table used to store configuration data must have the following structure:

Column Type Description
key string The configuration key (e.g., "App:Setting:Key").
value string The configuration value associated with the key.
environment string Used to filter configurations based on environment (e.g., "Development", "Production").

Make sure the table resides in the schema and table name specified in the AddNpgsql configuration.

For example, if the default schema (public) and table name (app_setting) are used, the SQL to create the table might look like this:

CREATE TABLE public.app_setting (
    key TEXT NOT NULL,
    value TEXT NOT NULL,
    environment TEXT NOT NULL
);

API Reference

Extension Method: AddNpgsql

Method Signature
public static IConfigurationBuilder AddNpgsql(
    IConfigurationBuilder builder,
    string connectionString,
    string environment,
    string schemaName = "public",
    string tableName = "app_setting"
);
Parameters
  • builder: The IConfigurationBuilder to which the Npgsql configuration source will be added.
  • connectionString: The connection string to the PostgreSQL database.
  • environment: The environment name used to filter configuration values.
  • schemaName: (Optional) The schema name in the database where the configuration table resides. Defaults to "public".
  • tableName: (Optional) The name of the table where configuration values are stored. Defaults to "app_setting".
Returns

The updated IConfigurationBuilder with the added PostgreSQL configuration provider.

Project Information

Dependencies


This library is ideal for scenarios where configuration values need to be dynamic, shared across services, or stored in a centralized relational database like PostgreSQL.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.2 584 4/14/2025
1.1.1 179 4/13/2025
1.1.0 190 4/13/2025
1.0.0 201 4/13/2025