Oip.Settings
2.0.0
See the version list below for details.
dotnet add package Oip.Settings --version 2.0.0
NuGet\Install-Package Oip.Settings -Version 2.0.0
<PackageReference Include="Oip.Settings" Version="2.0.0" />
<PackageVersion Include="Oip.Settings" Version="2.0.0" />
<PackageReference Include="Oip.Settings" />
paket add Oip.Settings --version 2.0.0
#r "nuget: Oip.Settings, 2.0.0"
#:package Oip.Settings@2.0.0
#addin nuget:?package=Oip.Settings&version=2.0.0
#tool nuget:?package=Oip.Settings&version=2.0.0
Oip.Settings
Application settings with an EF Core provider. Sources in order of priority:
- Command line argument
- Environment variables
- JSON file
- EF Core
Startup
- Create a settings class
public class AppSettings : BaseAppSettings<AppSettings>
{
public string TestString { get; set; } = "test";
public int TestInt { get; set; } = 1;
}
- Initialize settings with a ConnectionString from a JSON file, a command line argument or elsewhere
public class Program
{
public static void Main(string[] args)
{
// Initialize settings
AppSettings.Initialize(args);
var builder = WebApplication.CreateBuilder(args);
// Add settings db context
builder.Services.AddAppSettingsDbContext(AppSettings.Instance);
var app = builder.Build();
app.MapGet("/", () => $"AppSettings.Instance.TestInt: {AppSettings.Instance.TestInt}");
app.Run();
}
}
Connection string as a model
ConnectionString is written as a plain string in appsettings.json, but is available in code as a
ConnectionModel:
{
"ConnectionString": "XpoProvider=SQLite;Data Source=settings.db"
}
AppSettings.Instance.ConnectionString.Provider; // XpoProvider.SQLite
AppSettings.Instance.ConnectionString.NormalizeConnectionString; // Data Source=settings.db
AppSettings.Instance.ConnectionString.ConnectionString; // XpoProvider=SQLite;Data Source=settings.db
ConnectionString is typed as ConnectionModel and is the single place where the parsed connection string lives.
The former Provider, NormalizedConnectionString and Connection properties are removed, use
ConnectionString.Provider and ConnectionString.NormalizeConnectionString instead.
ConnectionModel has a TypeConverter, so any own property of this type is bound from a plain string too:
public class AppSettings : BaseAppSettings<AppSettings>
{
public ConnectionModel ReportConnection { get; set; } = default!;
}
{
"ReportConnection": "XpoProvider=Postgres;Server=localhost;Database=report;"
}
Sensitive data logging
SensitiveDataLogging is a custom connection string parameter, just like XpoProvider. It is stripped from
the normalized connection string and turns on EF Core sensitive data logging for the settings DbContext:
{
"ConnectionString": "XpoProvider=SQLite;SensitiveDataLogging=true;Data Source=settings.db"
}
AppSettings.Instance.ConnectionString.SensitiveDataLogging; // true
AppSettings.Instance.ConnectionString.NormalizeConnectionString; // Data Source=settings.db
Do not enable it in production: EF Core will then write parameter values into the log.
Running tests
Run all tests
dotnet test ./src/Oip.Settings.sln
Run tests that don't need external services
dotnet test ./src/Oip.Settings.sln --filter "TestCategory!=Integration"
Run only tests that need external services
dotnet test ./src/Oip.Settings.sln --filter "TestCategory=Integration"
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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. |
-
net6.0
- Mcrio.Configuration.Provider.Docker.Secrets (>= 1.0.1)
- Microsoft.EntityFrameworkCore (>= 6.0.36)
- Microsoft.EntityFrameworkCore.Design (>= 6.0.36)
- Microsoft.EntityFrameworkCore.InMemory (>= 6.0.36)
- Microsoft.EntityFrameworkCore.Sqlite (>= 6.0.36)
- Microsoft.EntityFrameworkCore.SqlServer (>= 6.0.36)
- Microsoft.Extensions.Configuration (>= 6.0.2)
- Microsoft.Extensions.Configuration.Binder (>= 6.0.1)
- Microsoft.Extensions.Configuration.CommandLine (>= 6.0.1)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 6.0.2)
- Microsoft.Extensions.Configuration.Json (>= 6.0.1)
- Microsoft.Extensions.Configuration.UserSecrets (>= 6.0.2)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 6.0.29)
-
net8.0
- Mcrio.Configuration.Provider.Docker.Secrets (>= 1.0.1)
- Microsoft.EntityFrameworkCore (>= 8.0.22)
- Microsoft.EntityFrameworkCore.Design (>= 8.0.22)
- Microsoft.EntityFrameworkCore.InMemory (>= 8.0.22)
- Microsoft.EntityFrameworkCore.Sqlite (>= 8.0.22)
- Microsoft.EntityFrameworkCore.SqlServer (>= 8.0.22)
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.2)
- Microsoft.Extensions.Configuration.CommandLine (>= 8.0.0)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 8.0.0)
- Microsoft.Extensions.Configuration.Json (>= 8.0.1)
- Microsoft.Extensions.Configuration.UserSecrets (>= 8.0.1)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 8.0.11)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Oip.Settings:
| Package | Downloads |
|---|---|
|
Oip.Base
Package Description |
|
|
Oip.Data
Package Description |
|
|
Oip.Api
Package Description |
|
|
Oip.Discussions
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.1 | 277 | 8/23/2026 |
| 2.0.0 | 95 | 8/22/2026 |
| 1.3.1 | 216 | 7/4/2026 |
| 1.3.0 | 2,072 | 12/20/2025 |
| 1.2.4 | 335 | 12/16/2025 |
| 1.2.3 | 554 | 12/5/2025 |
| 1.2.2 | 416 | 11/30/2025 |
| 1.2.1 | 167 | 11/29/2025 |
| 1.2.0 | 268 | 11/27/2025 |
| 1.1.10 | 258 | 11/22/2025 |
| 1.0.9 | 4,288 | 1/13/2025 |
| 1.0.8 | 197 | 12/24/2024 |
| 1.0.7 | 215 | 11/24/2024 |
| 1.0.6 | 286 | 6/1/2024 |
| 1.0.5 | 320 | 1/2/2024 |
| 1.0.4 | 250 | 12/31/2023 |
| 1.0.3 | 236 | 12/31/2023 |
| 1.0.2 | 225 | 12/31/2023 |
| 1.0.1 | 409 | 12/3/2023 |
| 1.0.0 | 245 | 11/30/2023 |