17
我在我的app.config文件中有以下內容。我正在使用Slow Cheetah,只是想替換替換配置/ entityFramework/defaultConnectionFactory /參數/參數,以便它指向一個diff服務器。即值數據源=一些服務器....轉換此節點的正確xdt:Locator參數是什麼?
<?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>
我試圖在app.config.release但無濟於事以下。
<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>
還試圖xdt:Locator="Match(parameter)"
和
,還有更多,但不能讓它開始工作。
不要覺得很傻,文檔一點都不清楚!感謝您發佈您的調查結果。 – 2014-05-01 15:54:12
我與有相同的問題。那個沒有用於匹配的名字,所以我只是用你的替換方法。 –
2016-12-07 16:28:55
@TobyJ - 文檔可能不是很清楚,但是當您考慮它時,定位器有助於調整默認位置匹配。如果你不給任何東西,元素的層次將被使用。 (如果沒有,你必須在鏈中的每個祖先元素上給xdt:Locator) – arviman 2017-06-12 09:05:48