title: The Requested Database is not defined in the configuration
body: <p>An application I am working on is using Microsoft Practices Enterprise to handle database interactions. </p>
  
  <p>This was all fine and good, however at some point it simply stopped working. The only thing I can think of is that I restored the database I was working on from another database deployed on a different machine (accessed by a user(s) with different accounts than the one I am using now).</p>
  
  <p>I have created 2 small tests (1 solution with 1 project having 1 class, <code>Program.cs</code>), the first works:</p>
  
  <pre><code>        static void test1()
          {
              // Create a connection
              SqlConnection sdwDBConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["Test"].ToString());
  
              // Open the connection
              sdwDBConnection.Open();
  
              // Create a String to hold the query.
              string query = "SELECT * FROM [TestDB].[dbo].[Test1]";
  
              // Create a SqlCommand object and pass the constructor the connection string and the query string.
              SqlCommand queryCommand = new SqlCommand(query, sdwDBConnection);
  
              // Use the above SqlCommand object to create a SqlDataReader object.
              SqlDataReader queryCommandReader = queryCommand.ExecuteReader();
  
              // Create a DataTable object to hold all the data returned by the query.
              DataTable dataTable = new DataTable();
  
              // Use the DataTable.Load(SqlDataReader) function to put the results of the query into a DataTable.
              dataTable.Load(queryCommandReader);
  
              // Example 1 - Print your  Column Headers
              String columns = string.Empty;
              foreach (DataColumn column in dataTable.Columns)
              {
                  columns += column.ColumnName + " | ";
              }
              Console.WriteLine(columns);
  
              // Close the connection
              sdwDBConnection.Close();
              System.Console.Read();
          }
  </code></pre>
  
  <p>Yielding:</p>
  
  <blockquote>
    <p>ID1 | Value1 | Value2 | Value3 |</p>
  </blockquote>
  
  <p>However the second one fails:</p>
  
  <pre><code>        static void test2()
          {
              try
              {
                  Database db = DatabaseFactory.CreateDatabase("Test");    //Line 59
                  using (DbCommand cmd = db.GetSqlStringCommand("SELECT * FROM [TestDB].[dbo].[Test1]"))
                  {
                      using (IDataReader reader = cmd.ExecuteReader())
                      {
                          while (reader.Read())
                          {
                              System.Console.WriteLine("{0} {1} {2}", reader.GetInt64(0)      
                              , reader.GetString(1) 
                              , reader.GetString(2));
                          }
                      }
                  }
              }
              catch (Exception e)
              {
                  System.Console.WriteLine(e.Message + "\n" + e.StackTrace);
              }
              finally
              {
                  System.Console.Read();
              }
          }
  </code></pre>
  
  <p>Yielding:</p>
  
  <pre><code>The requested database Test is not defined in configuration.
     at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp[T](IReadWriteLocator locator, ILifetimeContainer
   lifetimeContainer, String id, IConfigurationSource configurationSource)
     at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp[T](String id, IConfigurationSource configuration
  Source)
     at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase(String name)
     at ....Program.test2() in ...\Program.cs:line 59
  </code></pre>
  
  <p>This is my <code>app.config</code></p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" /&gt;    
    &lt;/configSections&gt;  
    &lt;dataConfiguration defaultDatabase="Test" /&gt;
    &lt;connectionStrings&gt;       
    &lt;add name="Test" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=TestDB;Integrated Security=SSPI; Connect Timeout=120" providerName="System.Data.SqlClient" /&gt;    
    &lt;/connectionStrings&gt;  
    &lt;startup&gt;
      &lt;supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" /&gt;
    &lt;/startup&gt;
    &lt;system.web&gt;
      &lt;membership defaultProvider="ClientAuthenticationMembershipProvider"&gt;
        &lt;providers&gt;
          &lt;add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" /&gt;
        &lt;/providers&gt;
      &lt;/membership&gt;
      &lt;roleManager defaultProvider="ClientRoleProvider" enabled="true"&gt;
        &lt;providers&gt;
          &lt;add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" /&gt;
        &lt;/providers&gt;
      &lt;/roleManager&gt;
    &lt;/system.web&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>I <em>think</em> that if there where any connection/configuration issue the first one would fail as well. I have tried using the empty constructor as well, but that just throws another exception saying that the <code>String</code> parameter must not be <code>null</code> or empty.</p>
  
  <p>Any insight on this would be appreciated.</p>