config.json-在ASP.NET vNext中添加数据库连接字符串 [英] config.json - Adding database connection strings in ASP.NET vNext

查看:53
本文介绍了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.

长话短说:

  1. 您需要一个或多个 Microsoft.Framework.ConfigurationModel.*应用程序中的NuGet软件包.可用软件包的列表位于此处.
  2. 添加所需的配置源
  3. 构建配置文件
  4. 阅读配置源
  1. You need one or more Microsoft.Framework.ConfigurationModel.* NuGet packages in your application. The list of available packages is here.
  2. Add the configuration sources that you need
  3. Build the config file(s)
  4. Read the configuration sources

这篇关于config.json-在ASP.NET vNext中添加数据库连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆