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.
XDT is a simple and straight forward method of transforming the web. config during publishing/packaging. Transformation actions are specified using XML attributes defined in the XML-Document-Transform namespace, that is mapped to the xdt prefix.
A Web. config transformation file contains XML markup that specifies how to change the Web. config file when it is deployed. You can specify different changes for specific build configurations and for specific publish profiles.
If you have a web application project, Right-click on web. config and choose Add Config Transform. This will add any config transforms that are missing from your project based on build configurations (i.e. if you have Production and Staging build configs, both will get a transform added).
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With