集中式数据库连接字符串商字符串、数据库连接、集中式

2023-09-06 23:03:53 作者:不若如初

我要建一个访问各种数据库的应用程序。 目前,连接字符串存储在app.config文件。 不过,我希望能够更轻松地配置数据库的连接字符串。

I'm building an application that accesses various databases. Currently the connection strings are stored in the App.Config file. However I'd like to be able to configure the connection strings for the database more easily.

我考虑有一个包含所有其他数据库的连接字符串一个主数据库。这意味着每个需要一个数据库连接的应用程序将查找从主数据库的连接。

I'm considering having a single "master" database that contains the connection strings for all the other databases. This would mean that each application that requires a database connection would lookup the connection from the master database.

app.config文件可以存储在表名的数据库连接字符串。这将允许应用程序的多个实例使用相同的主数据库有不同的表用于查找连接字符串。

The App.config file could store the table name for the database connection strings. This would allow for multiple instances of the application to use the same "master" database with a different table for looking up the connection strings.

有什么优势/这种方法的缺点是什么?

What are the advantages/disadvantages of this approach?

有没有人做过类似的事情?

Has anyone done something similar?

这被认为是最好的做法?

Is this considered a best practice?

推荐答案

如果你正在寻找一个集中的配置服务,那么不要再观望了的 StockTrader.Net 示例应用程序,其中包括与源一个​​完整的配置服务。

If you are looking for a centralised configuration service then look no further that the StockTrader.Net sample app which includes a complete config service with source.