I hate to be posting this as I see this particular issue has been raised so many times already.
I have a self servicing application that was generated from a catalog named OLD. I am attempting to change the catalog at runtime and am having no success. I've plowed through the posts and have tried recommendation I have found to no avail.
First, is catalog overwriting supported in self servicing?
If so, here is my config file.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="sqlServerCatalogNameOverwrites" type="System.Configuration.NameValueSectionHandler" />
</configSections>
<sqlServerCatalogNameOverwrites>
<add key="OLD" value="NEW" />
</sqlServerCatalogNameOverwrites>
<appSettings>
<add key="Main.ConnectionString" value="data source=SERVER;initial catalog=NEW;integrated security=SSPI;persist security info=False;packet size=4096"/>
</appSettings>
</configuration>
I've also tried this method:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Main.ConnectionString" value="data source=SERVER;initial catalog=NEW;integrated security=SSPI;persist security info=False;packet size=4096"/>
<add key="CatalogNameUsageSetting" value="2"/>
<add key="CatalogNameToUse" value="NEW" />
</appSettings>
</configuration>
I'm also setting the actual connection string in code:
private void button1_Click(object sender, EventArgs e)
{
DbUtils.SetSqlServerCompatibilityLevel(SqlServerCompatibilityLevel.SqlServer2005);
DbUtils.ActualConnectionString = "data source=SERVER;initial catalog=NEW;integrated security=SSPI;persist security info=False;packet size=4096";
CompanyEntity c3 = new CompanyEntity();
c3.FetchUsingPK(1);
MessageBox.Show(c3.CompanyName);
}
I've set the company name to "OLD" in the OLD database and "NEW" in the NEW database.
When I run the application, I get a messagebox showing "OLD".