ASP.Net配置文件->多个开发人员和部署服务器的连接字符串 [英] ASP.Net configuration file -> Connection strings for multiple developers and deployment servers

查看:51
本文介绍了ASP.Net配置文件->多个开发人员和部署服务器的连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由三个开发人员组成的团队,其中两个使用标准的本地测试数据库,其中一个使用自己的数据库,还有一个带有生产数据库和测试数据库的服务器环境。

I have a team of three developers, two of whom use a standard local test database, one of whom uses his own database and there is also a server environment with a production database and a testing database.

这等于需要多个连接字符串。

This amounts to multiple connection strings required.

web.config文件会定期更新,并且每次开发人员都必须对其进行更改执行源代码管理更新,以及有时开发人员不小心使用连接字符串签入其个人web.config文件更改的事实,这会在从源代码管理运行后续更新后暂时中断我们的运行。

The web.config file periodically gets updated and keeps having to be changed by each developer when a source control update is performed, as well as the fact that sometimes a developer accidentally checks in his personal web.config file change with his connection string, which temporarily interrupts us after running a subsequent update from source control.

我可以更改什么,以便可以根据需要多次提交/更新web.config文件,并且不会导致其他开发人员断开连接字符串,也不需要进行修改,然后才能将其上载到测试或生产环境?

What can I change so that the web.config file can be committed/updated as often as is necessary and not result in broken connection strings for other developers or require modifications before it can be uploaded to the testing or production environments?

推荐答案

您可能想看看用配置源文件替换Web.Config的ConnectionStrings部分,将连接字符串的LIVE组提交到源代码管理中,但将它们包括在实际解决方案中。

You might want to look at replacing the ConnectionStrings section of the Web.Config with a Config Source file, commit the LIVE set of connection strings into source control, but not include them in the actual solution.

使用configSource属性的信息可以在文档的使用外部配置文件部分中找到:

Information on using the configSource attribute can be found in the section "Using External Configuration Files" in the document:


连接字符串和配置文件

这样做的好处是,开发人员可以拥有自己的设置,而无需将其检入主Web.Config中。潜在的缺点是,这是您还需要担心的另一个文件,并且取决于您如何从源代码控制中获取最新版本,可能无济于事(即,如果您使用SC客户端并说获取最新,将会覆盖该文件,而如果您使用的是Visual Studio,则右键单击解决方案/项目,然后选择获取最新,该操作将仅获取项目中的文件。)

This has the advantage that developers could have their own settings that don't get checked into the main Web.Config. The potential downside is that it's yet another file that you have to worry about, and depending on how you're getting the latest version out of source control might not help (i.e. if you go to your SC client and say "Get latest" that would overwrite the file, whereas if you are in Visual Studio, right click on the solution/project and select "Get Latest" that will only get files in the projects).

这篇关于ASP.Net配置文件->多个开发人员和部署服务器的连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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