I'm trying to separate my connection string from my App.config, and as you can't do transformations like with Web.config, I thought may I could use the configSource attribute to point to another config file with the connection string in, but it doesn't seem to be working.
This works, App.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=*snip*" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
<connectionStrings>
<add name="DefaultConnection"
providerName="System.Data.SqlClient"
connectionString="Server=*snip*" />
</connectionStrings>
</configuration>
But this doesn't, App.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=*snip*" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
<connectionStrings configSource="connections.config" />
</configuration>
connections.config:
<connectionStrings>
<add name="DefaultConnection"
providerName="System.Data.SqlClient"
connectionString="*snip*" />
</connectionStrings>
I'm looking for the simplest of solutions.
Any ideas?


.configfiles in the same directory?DbContextwhich takes a connection string parameter, so I pass to that DefaultConnection. It works when the connectionString is defined in the App.config but not in the separate file.configSource).{"The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception."}and{"Unable to open configSource file 'connections.config'. (*project directory*\\bin\\Debug\\TestApp.vshost.exe.config line 17)"}which makes me wonder if it isn't copying the other config file to the build directory...