web config transform如何使用config变换将两个连接字符串转换为一个?

时间:2016-07-11 07:35:58

标签: asp.net asp.net-mvc web-config web-config-transform

我的MVC 5应用程序中有两个数据库。一个是memmbership数据库,另一个是应用程序数据库。我想将数据库合并到一个数据库中 并在项目的Package / Publich SQL属性中为两个数据库设置相同的目标数据库。我还为web.config文件创建了一个配置转换。 这就是它的外观。

    <connectionStrings>
          <add name="DefaultConnection" 
    connectionString="Data Source=DESKTOP-0CKI1SE;Initial Catalog=DT;User ID=test;Password=test1234"
    xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
          <add name="DriversTrainingEntities"
   connectionString="Data Source=DESKTOP-0CKI1SE;Initial Catalog=DT;User ID=test;Password=test1234"
   xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
    </connectionStrings>

部署应用程序后,将为成员资格数据库DefaultConnection完美地创建架构。但对于应用程序数据库,我收到错误 “不支持关键字:'数据源'”。我想这是因为我为目标数据库添加了两次连接字符串。如何更改配置 两个数据库只有一次?

0 个答案:

没有答案
相关问题