In this tutorial I’ll be showing you how to push a Git repository for a .NET solution site to AppHarbor.
This follows on from the tutorial for adding a ASP.NET MVC solution to a Git repository.
The first steps are to create an AppHarbor account if you haven’t got one, and then create an application
on the following page keep a note of the URLs where you’ll be pushing your Git repository to
In the directory containing your ASP.NET MVC solution start Git Bash, or start Git Bash and navigate to the directory.
Execute the following commands (substituting your URLs) to push your ASP.NET MVC solution to AppHarbor.
git remote add appharbor https://firstname.lastname@example.org/MvcMusicStoreDemo.git
git push appharbor master
When you’re prompted to enter your password, use the same one for your AppHarbor account.
Next go to the build page on AppHarbor to see the status of your app.
If you’re following along with the example to deploy the ASP.NET MVC Music Store to AppHarbor you’ll see the site doesn’t work yet.
That’s because you can’t use MDF database files in AppHarbor yet so the next step is create the ASP.NET MVC Music Store SQL Server database in AppHarbor.
In the last part of the tutorial about how to deploy ASP.NET MVC applications to AppHarbor we pushed an ASP.NET MVC site to AppHarbor.
Although the build was successful an error occured when viewing the site becuase it couldn’t connect to the attached database.
To fix this we need to create a SQL Server Database in Appharbor.
On the AppHarbor application management page click the link to ‘Add database’
Next choose SQL Server as the database type, enter a connection string name and click the create button.
I used the same connection string name used by Entity Framework 4 in the ASP.NET MVC Music Store application.
The following screen shows you what connection string should be used in your config file and information about how to connect to the Appharbor database from Microsoft SQL Server Managemnt Studio.
When you connect to the database in Microsoft SQL Server Managemnt Studio you’ll see the database is empty.
In the Assets/Data folder in the ASP.NET MVC Music Store you’ll find a ‘MvcMusicStore-Create.sql’ SQL script which can be used to create and populate the tables required by the application.
Before running the script delete the first line that looks like this
When the script has been completed successfully the tables will have been created and populated
In the next step of this tutorial we will see how to configure ASP.NET MVC to use a SQL Server database in AppHarbor.
In this tutorial about how to deploy ASP.NET MVC applications to AppHarbor is to update the ASP.NET MVC web.config file, commit the change and push the Git repository to AppHarbor.
Modify the connection string in the ASP.NET MVC web.config to use the AppHarbor database created in last tutorial.
In the directory containing your ASP.NET MVC solution, right click and start Git Bash, or start Git Bash and navigate to the directory.
Execute the following commands to commit the updated web.config file in the git repository and push to AppHarbor
git add MvcMusicStore/web.config
git commit –m "Now using AppHarbor SQL Server"
git push appharbor master
Once the appliation has been built you should have a working ASP.NET MVC Music store running in AppHarbor.