The provider reads a database table into configuration at startup.To use a database that requires a connection string, get a connection string from an interim configuration.The EF in-memory database is used for demonstration purposes.The provider has the following characteristics: Psn stuff custom database how to# Protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) Public Entit圜onfigurationContext(string connectionString) => Private readonly string _connectionString Public class Entit圜onfigurationContext : DbContext Providers/Entit圜onfigurationContext.cs: using Public record Settings(string Id, string Value) įor information on record types, see Record types in C# 9.Īdd an Entit圜onfigurationContext to store and access the configured values.įor example, you could add a Settings.cs file in your Models folder: namespace Reload-on-change isn't implemented, so updating the database after the app has started will not affect the app's configuration.ĭefine a Settings record type entity for storing configuration values in the database.The provider doesn't query the database on a per-key basis.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |