I am using an abstract class to get the ConnectionString from my App.config file. However instead of the ConnectionString specified the app comes up with ...
{data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true}
I have no idea where this connection string came from. I don't have SQL Express installed. I know the proper App.config is not be accessed because I added a dummy connection string named foo
and only one connection string is picked up when I step through debugging instead of two. It's like the app is getting the connection string from another App.config!
Here is my class
using System;
using System.Configuration;
namespace MyApiUpdater.Data
{
public abstract class ConnectionAccess
{
protected string ConnectionString
{
get
{
return ConfigurationManager.ConnectionStrings["MyDatabase"].ConnectionString;
}
}
}
}
and here is my App.config file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="MyDatabase" connectionString="Server=MyDatabaseServer;Database=MyDBName;Trusted_Connection=True;" />\
<add name="foo" connectionString="Server=MyDatabaseServer;Database=MyDBName;Trusted_Connection=True;" />
</connectionStrings>
</configuration>