0

I am running SQL Server unit tests and have two test databases on which I want to test, "A" and "B". In my VSTS Release definition, I deploy my DACPAC files for both of these test DBs to the same server. In my app.config file that is copied to the build output, I have the following connection string, which references database "A" as the "Initial Catalog":

<SqlUnitTesting>
    <DataGeneration ClearDatabase="true" />
    <ExecutionContext Provider="System.Data.SqlClient" ConnectionString="Data Source=XYZ;Initial Catalog=A;Integrated Security=True;Pooling=False"
        CommandTimeout="30000" />
    <PrivilegedContext Provider="System.Data.SqlClient" ConnectionString="Data Source=XYZ;Initial Catalog=A;Integrated Security=True;Pooling=False"
        CommandTimeout="30000" />
</SqlUnitTesting>

If I also want to connect to database "B", how can I do this?

  • Could I create two Initial Catalogs in the same connection string?
  • Could I create two configSections, where one has the connection string refer to "A" and the other refers to "B"?
  • Could I remove Initial Catalog from my connection string so that it does not only limit me to "A"?
  • Could I create two app.config files and have them in the same location?

Thank you.

4

1 回答 1

0

回答我自己的问题。我了解到每个项目都有自己的 app.config,当项目构建时,它们会以 .dll.config 文件的形式输出。在其中的每一个中,我都指定了相同的服务器,但我使用不同的数据库作为初始目录值。通过这样做,每个项目都会查看其各自的 .dll.config 并成功建立数据库连接。

于 2016-11-15T18:17:49.210 回答