一台服务器上的ConnectionString管理的很多项目,我应该让我自己的ConnectionString提供商,为code [英] ConnectionString management for many projects on one server, should I make my own ConnectionString provider for our code

查看:136
本文介绍了一台服务器上的ConnectionString管理的很多项目,我应该让我自己的ConnectionString提供商,为code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows Server上的约10个不同的.NET项目,主要是.NET 4.0,但是一些.NET 2.0

I have on a single Windows Server about 10 different .NET projects, mostly .NET 4.0 but some .NET 2.0

有些项目是asp.net,有些是后台实用程序/服务。

Some of these projects are asp.net, some are background utilities/services.

这些项目在我们的基础设施一百多个不同的数据库进行交互。该的ConnectionStrings他们使用做了几次修改至少一个月。

These projects interact with over a hundred different databases in our infrastructure. The ConnectionStrings they use to do that changes at least a few times a month.

这里的问题是,忘了把的ConnectionString在这些项目中的一个可能会导致很多问题,和新的项目/更新由许多不同的程序员部署到服务器上所有的时间。

The issue here is that forgetting to put a ConnectionString in one of these projects can cause a lot of problems, and new projects/updates are deployed to the server all the time by many different programmers.

我的新尝试的解决方案是重写System.ConfigurationManager类中的所有项目,它与我自己的实现,它读出一个共享的配置文件,我可以保持取代。然后,我只想重新编译每个项目一次并部署它。

My new attempt at a solution is to override the System.ConfigurationManager class in all projects and replace it with my own implementation that reads from a shared config file that I can maintain. Then I would just recompile each project once and deploy it.

我也可以尝试保持这一切项目之间共享Machine.config文件中的ConnectionStrings,但我必须这样做,每一个版本的.NET框架中使用的一个项目,该项目至少是三,并使在这个文件中的错误,好像它可能是危险的。

I could also try to maintain the ConnectionStrings in the machine.config file that's shared between all projects, but I would have to do it for every version of the .NET framework used by a project which is at least three, and making a mistake in this file seems like it could be dangerous.

是否有人有进行哪种方式的建议?

Does anybody have a recommendation of which way to proceed?

感谢。

推荐答案

除了machine.config中,您可以创建常见的appSettings文件。你不会需要开发任何新的东西,只是把你的共享设置该文件,并引用它在特定的配置文件。

Besides the machine.config, you can create common appSettings files. You won't need to develop anything new, just place your shared settings on this file and reference it on your specific config files.

希望这有助于。

这篇关于一台服务器上的ConnectionString管理的很多项目,我应该让我自己的ConnectionString提供商,为code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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