如何创建解决方案范围的连接字符串 [英] How do I create a Solution Wide Connection String

查看:85
本文介绍了如何创建解决方案范围的连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道是否可以创建一个解决方案中所有项目都可以访问的单个连接字符串(大约有6个).

Does anyone know if it is possible to create a single connection string that will be accessible to all the projects in a solution (we have about 6).

我可以使用此信息创建一个文本文件,但是我们也需要设计时间支持,并且在解决方案中的每个App.Config和Web.config文件中都有一个连接字符串是不切实际的.

I can create a text file with this information, but we need design time support as well, and it is not practical to have a connection string in every App.Config and Web.config file in the solution.

我们基本上想要一个Single连接字符串,如果db的位置发生更改,该字符串很容易更改,IDE还将使用它来提供设计时间支持

We basically want a Single connection string that is easy to change should the location of the db change, that will also be used by the IDE for design time support

推荐答案

不确定,您能否仅将新的配置文件放到解决方案项中,然后将其包含并加载到所有项目中?

Not sure, can't you just put a new config file to the solution items and include and load it in all projects?

我专门谈论的是常规(XML)配置文件,而不是"App.config".是具有完全相同的格式,只是名称不同而已.将此文件添加到解决方案项中,并使用 OpenMappedExeConfiguration . 您可以在此处找到另一个示例.

I am specifically talking about a general (XML) config file, not an "App.config". Is has exactly the same format, it just goes by a different name. Add this file to your solution items and access it using OpenMappedExeConfiguration. You can find an additional example here.

这篇关于如何创建解决方案范围的连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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