pvNugsCsProviderNc9Abstractions 9.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package pvNugsCsProviderNc9Abstractions --version 9.0.0
                    
NuGet\Install-Package pvNugsCsProviderNc9Abstractions -Version 9.0.0
                    
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="pvNugsCsProviderNc9Abstractions" Version="9.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="pvNugsCsProviderNc9Abstractions" Version="9.0.0" />
                    
Directory.Packages.props
<PackageReference Include="pvNugsCsProviderNc9Abstractions" />
                    
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 pvNugsCsProviderNc9Abstractions --version 9.0.0
                    
#r "nuget: pvNugsCsProviderNc9Abstractions, 9.0.0"
                    
#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 pvNugsCsProviderNc9Abstractions@9.0.0
                    
#: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=pvNugsCsProviderNc9Abstractions&version=9.0.0
                    
Install as a Cake Addin
#tool nuget:?package=pvNugsCsProviderNc9Abstractions&version=9.0.0
                    
Install as a Cake Tool

pvNugsCsProviderNc9Abstractions

A .NET library providing abstractions for managing database connection strings with role-based access control. This package defines the core interfaces and contracts for connection string providers without being tied to any specific database technology.

Features

  • Role-based connection string management
  • Database-agnostic connection string provider abstractions
  • Support for dynamic credentials
  • Schema-aware configuration
  • Async-first design
  • Clean separation between abstractions and implementations
  • .NET 9.0 target framework support

Installation

Install the package via NuGet:

dotnet add package pvNugsCsProviderNc9Abstractions

Usage

Basic Connection String Provider

// Inject the provider
public class MyService
{
    private readonly IPvNugsCsProvider _connectionStringProvider;

    public MyService(IPvNugsCsProvider connectionStringProvider)
    {
        _connectionStringProvider = connectionStringProvider;
    }

    public async Task ConnectToDatabase()
    {
        // Get connection string with default reader role
        string connectionString = await _connectionStringProvider.GetConnectionStringAsync();
        
        // Or specify a different role
        string ownerConnectionString = await _connectionStringProvider.GetConnectionStringAsync(SqlRoleEnu.Owner);
    }
}

Database-Specific Provider Interface

// Example using a database-specific provider interface
public class MyDatabaseService
{
    private readonly IDatabaseSpecificCsProvider _provider;

    public MyDatabaseService(IDatabaseSpecificCsProvider provider)
    {
        _provider = provider;
    }

    public void ConfigureConnection()
    {
        // Access database-specific properties
        string schema = _provider.Schema;
        string username = _provider.UserName;
        bool usesDynamicCreds = _provider.UseDynamicCredentials;
        SqlRoleEnu currentRole = _provider.Role;
    }
}

Available Roles

The package defines three levels of database access roles:

  • SqlRoleEnu.Owner - Highest privilege level with full database control
  • SqlRoleEnu.Application - Standard application-level privileges with write access
  • SqlRoleEnu.Reader - Read-only access level

Architecture

This abstractions package provides:

  • Core interfaces for connection string providers
  • Role enumeration for access level management
  • Base contracts for database-specific implementations
  • Async patterns for modern application development

The actual database-specific implementations are provided in separate packages that depend on this abstraction layer, ensuring clean separation of concerns and testability.

Dependency Injection

// Register your chosen implementation
services.AddSingleton<IPvNugsCsProvider, YourDatabaseCsProvider>();

// Or use with factory pattern
services.AddSingleton<ICsProviderFactory, CsProviderFactory>();

Implementation Guidelines

When implementing the interfaces from this package:

  • Thread Safety: Ensure implementations are thread-safe
  • Configuration: Support various configuration sources
  • Security: Handle credentials securely
  • Error Handling: Provide meaningful error messages
  • Logging: Integrate with logging frameworks appropriately

Requirements

  • .NET 9.0 or higher

This abstractions package works with database-specific implementation packages:

  • Implementation packages for various database providers
  • Extensions for specific frameworks and scenarios
  • Testing utilities and mocks

License

MIT

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.
  • net9.0

    • No dependencies.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on pvNugsCsProviderNc9Abstractions:

Package Downloads
pvNugsLoggerNc9MsSql

Package Description

pvNugsCsProviderNc9PgSql

Secure, production-ready PostgreSQL connection string provider for .NET 9.0+ with advanced credential management, role-based access, and automatic secret rotation.

pvNugsCsProviderNc9MsSql

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.0.3 117 9/26/2025
9.0.2 195 9/10/2025
9.0.1 198 8/28/2025
9.0.0 189 8/27/2025

Initial