-
Notifications
You must be signed in to change notification settings - Fork 13
Add settings to the Repository
Patrick edited this page Nov 2, 2016
·
4 revisions
The repository can be populated via a script, database tooling or even the EntityFrameworkCore ConfigurationContext.
Before inserting data, it is important that you understand how to categorize your data.
using (var context = new ConfigurationContext())
{
var section = new SectionEntity() { ApplicationName = "Sample", SectionName = "appSettings", Aspect = "settings" };
context.Sections.Add(section);
context.SaveChanges();
var setting = new SettingEntity() { SectionId = section.Id, Key = "TestSetting", Json = @"""Test Value""" };
context.Settings.Add(setting);
context.SaveChanges();
}
using (var context = new ConfigurationContext())
{
var complex = new ComplexType()
{
Id = Guid.NewGuid(),
Name = "ComplexTypeName"
};
var section = new SectionEntity() { ApplicationName = "SampleApplication", SectionName = "SampleComplexTypeSection" };
context.Sections.Add(section);
context.SaveChanges();
var setting = new SettingEntity() { SectionId = section.Id, Key = "SampleComplexType" };
setting.SetValue(complex);
context.Settings.Add(setting);
context.SaveChanges();
}