Ich versuche connection an externe Datei zu bewegen EntLib verwenden, aberEnterprise Library: Abschnitt connection Umleiten hinzufügen keine neuen Connection zu ConfigurationManager.ConnectionStrings
ConfigurationManager.ConnectionStrings
gibt mir nur ASP.NET-Datenbank standardmäßig, die nicht einmal in Konfig.
Ich erwartete, dort zwei Verbindungszeichenfolge von shared.config zu sehen. Was kann das Problem sein, oder habe ich ein falsches Verständnis dieser Funktion?
App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<enterpriseLibrary.ConfigurationSource selectedSource="System Configuration Source">
<sources>
<add name="System Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="Shared" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
filePath="shared.config" />
</sources>
<redirectSections>
<add sourceName="Shared" name="connectionStrings" />
</redirectSections>
</enterpriseLibrary.ConfigurationSource>
</configuration>
shared.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="connStr1" connectionString="Data Source=local;Initial Catalog=DB1;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="connStr2" connectionString="Data Source=local;Initial Catalog=DB2;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
Als ich sah, Verbindungszeichenfolgen in ihrem Konfigurationstool umleiten dachte ich, es unterstützt default Section Redirect. Traurig, habe ich fast existiert :) Standard-Redirect-Mechanismus erlaubt nicht diese coolen Funktionen zum Erben und Zusammenführen von Konfigurationen – aershov
Ich werde die Antwort aktualisieren – hal