-
Notifications
You must be signed in to change notification settings - Fork 13
Categorization of Data
The Configuration.EntityFramework provider supports the following categorization of data
Configuration data can be associated with a particular application. When accessing settings via the .NET Core Configuration System, you can nominate to only retrieve settings for the current application.
The Configuration Section allows settings to be grouped based on a common responsibility such as 'connectionStrings'. A section may also represent a complex type which has been serialized into a Json formatted string.
In addition to 'Application' and 'Section' you can now categorize data based on 'Aspect'. An aspect represents a cross-cutting concern within an application such as Culture related strings. If you're using the Configuration database to store such data, it should be returned via the IStringLocalizer and not the ConfigurationProvider. While .NET Core comes with a IStringLocalizer for ResourceFiles, [Configuration.EntityFramework.Localization[(https://github.com/thinkabouthub/Configuration.EntityFramework.Localization/wiki) provides a custom IStringLocalizer called EFStringLocalizer which will retrieve Culture related strings from the Configuration Database.
So that the ConfigurationProvider does not retrieve data related to the localization aspect, by default, it will only return data where the Aspect is set to 'settings'.
Likewise, the EFStringLocalizer will only retrieve string values where the Aspect is set to 'localization'.
- By default, the [Configuration.EntityFramework] (https://www.nuget.org/packages?q=configuration.entityframework) provider will retrieve data where the Aspect is set to 'settings'.
- The EFStringLocalizer located in Configuration.EntityFramework.Localization will retrieve string values where the Aspect is set to 'localization'.
Define application settings
ApplicationName | Aspect | Section |
---|---|---|
PayrollWebAPI | Application | appSettings |
PayrollWebAPI | Application | connectionStrings |
Define localized strings for Australia and France compatible with EFStringLocalizer
ApplicationName | Aspect | Section |
---|---|---|
PayrollWebAPI | Localization | en-AU |
PayrollWebAPI | Localization | fr-FR |
With the Configuration.EntityFramework provider, data can be categorized based on Application, Section and Aspect. However, if greater granularity is required then the Discriminator field can be used. With the Discriminator field, a configuration section can be categorized via a collection of Key-Value pairs defined using a Json formatted string.
Segment appSettings for UserA and UserB
ApplicationName | Aspect | Section | Discriminator |
---|---|---|---|
PayrollWebAPI | Application | appSettings | {"Username":"UserA"} |
PayrollWebAPI | Application | appSettings | {"Username":"UserB"} |
Segment appSettings related to Test Environment for UserA and UserB
ApplicationName | Aspect | Section | Discriminator |
---|---|---|---|
PayrollWebAPI | Application | appSettings | {"Environment":"Testing", "Username":"UserA"} |
PayrollWebAPI | Application | appSettings | {"Environment":"Testing", "Username":"UserB"} |
The Configuration.EntityFramework provider now allows for the segmentation of settings based on a Tenant Identifier.