title: ASP.NET MVC - Switching from SQL Server Express to Compact Edition - Connection Issue
body: <p>I have a ASP.NET MVC 4 project - <strong>CodeFirst with Entity Framework</strong> - that was connected to a SQL Server Express database generated by EF and it was working just fine.</p>
  
  <p>However, I am trying to deploy to AppHarbor and having some issues with the version of SQL running there connecting with my app.</p>
  
  <p>So, I noticed that they have an example project that is utilizing SQL Server Compact Edition 4.  Here is the web.config file for that project:  <a href="https://github.com/friism/CodeFirstMigrations/blob/master/Web/Web.config" rel="nofollow">https://github.com/friism/CodeFirstMigrations/blob/master/Web/Web.config</a></p>
  
  <p>Also, I found a tutorial about how to include a SQL Server CE database in your project on Microsoft's ASP.NET site:  <a href="http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-4" rel="nofollow">http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-4</a></p>
  
  <p>I decided to create a <code>FranchiseManagerData.sdf</code> file in my <strong>App_Data</strong> folder and modify my connection string and app settings to match theirs.  Here's what my Web.config looks like:</p>
  
  <pre><code>&lt;appSettings&gt;
      &lt;add key="webpages:Version" value="2.0.0.0" /&gt;
      &lt;add key="ClientValidationEnabled" value="true" /&gt;
      &lt;add key="UnobtrusiveJavaScriptEnabled" value="true" /&gt;
    &lt;/appSettings&gt;
  
    &lt;connectionStrings&gt;
      &lt;add name="FranchiseManagerEntities"
           connectionString="Data Source=|DataDirectory|FranchiseManagerData.sdf"
           providerName="System.Data.SqlServerCe.4.0"/&gt;
    &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>When I run my application, I get a DataException error that says:  <code>The underlying provider failed on Open.</code></p>
  
  <p>It looks like what is happening is that the application is still looking for the old database that was generated by Entity Framework that had the name:  <code>FranchiseManagerTest.Models.FranchiseManagerContext</code> - EF was naming it after my data context class.</p>
  
  <p>Here is the error that is displayed after stopping debugging: </p>
  
  <pre><code> Cannot open database "FranchiseManagerTest.Models.FranchiseManagerContext" requested by the login. The login failed.
  Login failed for user 'COMPANY\UserName'.
  </code></pre>
  
  <p>I have tried cleaning and rebuilding the solution.  Also, I've deleted the contents of the bin folder and did a clean rebuild again, however, it still seems to be looking for the old database connection.</p>
  
  <p>What am I doing wrong?  How can I get my project to look for the local SQL Server CE database I made and not the previous database?</p>
  
  <p>If I need to supply any further details please let me know.</p>
  
  <p><strong>Thanks in advance.</strong></p>
  
  <hr>
  
  <h2>EDIT</h2>
  
  <p>Here is a portion of the System.Web section of my Web.config file:</p>
  
  <pre><code>&lt;compilation debug="true" targetFramework="4.0" /&gt;
  &lt;customErrors mode="Off"&gt;&lt;/customErrors&gt;
  &lt;authentication mode="Forms"&gt;
    &lt;forms loginUrl="~/Account/Login" timeout="2880" /&gt;
  &lt;/authentication&gt;
  </code></pre>