What is the right xdt:Locator parameter to transform this node?

etoisarobot picture etoisarobot · Mar 23, 2013 · Viewed 17.1k times · Source

I have the following in my app.config file. I am using Slow Cheetah and just want to replace replace configuration/entityFramework/defaultConnectionFactory/parameters/parameter so it points to a diff server. ie value-data source=some-server....

    <?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <appSettings>
  </appSettings>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
  </startup>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="data source=.;Integrated Security=SSPI;Initial Catalog=SomeDb;MultipleActiveResultSets=true" />
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>
  <system.web>
    <membership defaultProvider="ClientAuthenticationMembershipProvider">
      <providers>
        <add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
      </providers>
    </membership>
    <roleManager defaultProvider="ClientRoleProvider" enabled="true">
      <providers>
        <add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
      </providers>
    </roleManager>
  </system.web>
</configuration>

I have tried to the following in the app.config.release but to no avail.

  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="data source=dbserver;Integrated Security=SSPI;Initial Catalog=someDb;MultipleActiveResultSets=true" 
                   xdt:Transform="Replace" 
                   xdt:Locator="XPath(configuration/entityFramework/defaultConnectionFactory/parameters/parameter)" />
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>

also tried xdt:Locator="Match(parameter)" and xdt:Locator="XPath(parameter)

and many more but can't get it to work.

Answer

etoisarobot picture etoisarobot · Mar 24, 2013

Ok. I feel a little silly but the solution is that I didn't need to specify a xdt:Locator.

If I just leave the App.Release.Config like this it will replace matching entry.

 <parameter value="data source=dbserver;Integrated Security=SSPI;Initial Catalog=someDb;MultipleActiveResultSets=true" 
               xdt:Transform="Replace"/>
  </parameters>