config.json-在ASP.NET vNext中添加数据库连接字符串 [英] config.json - Adding database connection strings in ASP.NET vNext
本文介绍了config.json-在ASP.NET vNext中添加数据库连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在学习ASP.NET vNext.我需要在config.json文件中存储两个连接字符串.我该如何存储?我可以这样做吗?
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=..."
}
}
我无法找到 config.json
的架构.因此,我不确定该怎么做.我在此处中看到了 IConfiguration
的使用.不过,我不确定应用程序中如何提供 Configuration
.
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.
长话短说:
- You need one or more
Microsoft.Framework.ConfigurationModel.*
NuGet packages in your application. The list of available packages is here. - Add the configuration sources that you need
- Build the config file(s)
- Read the configuration sources
这篇关于config.json-在ASP.NET vNext中添加数据库连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文