This post is really just a reminder to myself, because I always forget this one darn step when deploying an ASP.NET site that uses EF CodeFirst to AppHarbor.
Normally, I would do some local development and use SQL Server Local DB, which by default will make a connection string that looks like this in the App.config file:
<connectionStrings> <add name="DashboardEntities" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\DashboardEntities.mdf;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings>
Before deploying to AppHarbor you will want to set up SQL Server. This means going to AppHarbor, creating your new application, and then adding a SQL Server service to it (I just use the free one).
Now this is the one step I always forget to do…
Before you deploy your code, go to the SQL Server settings page on AppHarbor. Then click the Go To SQL Server link. By default it will have a Connectionstring alias of (unknown). Click on the Edit Alias link, and set the alias to the “name” attribute of your EF connection string. So in my example above, I want my alias to be set to “DashboardEntities”.
Now the app can be deployed to AppHarbor and it will properly replace the EF connection string. Yay!