var config = new ConfigurationBuilder() .AddJsonFile("settings.json", optional: true, reloadOnChange: true) .Build(); config["Greeting"] = "Hello, World!"; var configPath = Path.Combine(Environment.CurrentDirectory, "settings.json"); var fileConfigSource = new JsonConfigurationSource { Path = configPath }; fileConfigSource.Save(config);
var config = new ConfigurationBuilder() .AddMySql(connectionString) .Build(); config["Greeting"] = "Hello, World!"; var databaseConfigSource = new MySqlConfigurationSource { ConnectionString = connectionString }; databaseConfigSource.Save(config);In this example, we load configuration data from a MySQL database using the `ConfigurationBuilder` class. Then, we modify a configuration value and save the updated configuration data back to the same database using the `MySqlConfigurationSource`. Package library: `Pomelo.EntityFrameworkCore.MySql`