An ADO.NET extension for centralizing application settings in a database store. Each setting class corresponds to a table, with each table having a single-row configuration.
A specialized JSON settings manager uses the JSON ADO.NET Provider
- Easy Setup: Integrate with your existing EF Core projects seamlessly.
- Centralized Settings: Store and manage your app settings in a unified manner.
- Single-row Configurations: Each setting class corresponds to a table with a unique configuration row.
- .NET Framework 4.6.1/.NET 7 or higher
- An ADO.NET Data Provider to use for storage
- Install the
ServantSoftware.SettingsOnADO
package via NuGet:
dotnet add package ServantSoftware.SettingsOnADO
Package Name | Release (NuGet) |
---|---|
ServantSoftware.SettingsOnADO |
- Define your settings class with properties of simple data types. Here is an example:
namespace SettingsOnADO.Tests.TestClasses;
public class TestSettings
{
public int Id { get; set; }
public string Name { get; set; }
}
- Use the Get and Update methods from SettingsManager to retrieve and update settings:
// Set up a connection to the ADO.NET Data Provider (as needed)
var connection = new SqliteConnection("Data Source=:memory:");
connection.Open();
// Initialize SchemaManager with the connection
var schemaManager = new SchemaManager(connection);
var setting = settingsManager.Get<TestSettings>();
setting.Name = "MyName";
settingsManager.Update(setting);
For more detailed documentation, check our Wiki.
SettingsOnADO provides a default AES-based encryption provider. Here’s how to use it:
using SettingsOnADO;
// Set up a connection to the ADO.NET Data Provider (as needed)
var connection = new SqliteConnection("Data Source=:memory:");
connection.Open();
// Define key and IV (ensure proper key length for AES)
byte[] key = Encoding.UTF8.GetBytes("your-256-bit-key"); // 32 bytes
byte[] iv = Encoding.UTF8.GetBytes("your-128-bit-iv"); // 16 bytes
var encryptionProvider = new AesEncryptionProvider(key, iv);
var settingsManager = new SettingsManager(connection, true, encryptionProvider);
// Now you can use settingsManager to get and update settings with encryption.
Here is an example of how to use DataProtectionProvider
with the SettingsOnADO
library:
using Microsoft.AspNetCore.DataProtection;
using SettingsOnADO;
// Set up a connection to the ADO.NET Data Provider (as needed)
var connection = new SqliteConnection("Data Source=:memory:");
connection.Open();
var dataProtectionProvider = DataProtectionProvider.Create("SettingsOnADO");
var encryptionProvider = new DataProtectionEncryptionProvider(dataProtectionProvider);
var settingsManager = new SettingsManager(connection, true, encryptionProvider);
// Now you can use settingsManager to get and update settings with encryption.
We welcome contributions to SettingsOnADO! Here's how you can help:
- Fork the repository on GitHub.
- Clone your fork locally.
- Commit your changes on a dedicated branch.
- Push your branch to your fork.
- Submit a pull request from your fork to the main repository.
- Engage in the review process and address feedback.
Please read our CONTRIBUTING.md for details on the process and coding standards.
No extra threading safeguards have been put in place, other than what is provided by the ADO.NET Data Provider that is used. It is up to the consumer of this library to put proper synchronization in place.
Feel free to submit issues and enhancement requests.
SettingsOnADO is licensed under the MIT License. See LICENSE for more information.