I am in the process of learning ASP.NET vNext. I need to store two connection strings in the config.json file. How do I store those? Can I do this:
config.json
{
"connectionStrings" : {
"connection-1" : "server=...",
"connection-2" : "server=..."
}
}
I have not been able to find a schema for config.json
. For that reason, I wasn't sure how to do it. I saw the use of IConfiguration
here. Still, I wasn't sure how Configuration
was available in the app.
This is the official Configuration repo and this is a great blog post explaining the configuration system.
Long story short:
Microsoft.Framework.ConfigurationModel.*
NuGet packages in your application. The list of available packages is here.Here is how you can do it:
{
"Data": {
"connection-1": {
"ConnectionString": "Server=..."
},
"connection-2": {
"ConnectionString": "Server=..."
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With