How to push a ASP.NET MVC Git repository to AppHarbor

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

Create AppHarbor App



on the following page keep a note of the URLs where you’ll be pushing your Git repository to

App Harbor URLs



In the directory containing your ASP.NET MVC solution start Git Bash, or start Git Bash and navigate to the directory.

Git Directory Location To Push



Execute the following commands (substituting your URLs) to push your ASP.NET MVC solution to AppHarbor.

git remote add appharbor https://jagreehal@appharbor.com/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.

App Harbor Build



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.

How To Create a 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’

App Harbor Build

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.

New AppHarbor Database



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.

Database Connection Settings



When you connect to the database in Microsoft SQL Server Managemnt Studio you’ll see the database is empty.

Empty AppHarbor Database



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

USE [C:\USERS\JON\DOCUMENTS\JON-SHARE\MVCMUSICSTORE-MVC3\MVCMUSICSTORE\MVCMUSICSTORE\APP_DATA\MVCMUSICSTORE.MDF]

When the script has been completed successfully the tables will have been created and populated

Populated AppHarbor Database



In the next step of this tutorial we will see how to configure ASP.NET MVC to use a SQL Server database in AppHarbor.

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.

<connectionStrings>
  <add name="MusicStoreEntities" 
        connectionString="Server=db003.appharbor.net;Database=db1814;User ID=db1814;Password=<yourpassword>"
        providerName="System.Data.SqlClient" />
</connectionStrings>

In the directory containing your ASP.NET MVC solution, right click and start Git Bash, or start Git Bash and navigate to the directory.

Git Directory Location To Push



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.

Working Music Store In AppHarbor

Page 4 of 23« First...23456...1020...Last »