MVC3 Docking on AppHarbor and Entity Framework Code First

So, I spent last few hours figuring this out. AppHarbor is pretty nice. AppHarbor is free for one application, one database and it does work with SQL Server CE. I just deployed a stripped down version of one of my MVC projects there and it’s pretty smooth. So, here’s a run down of how it’s done, so that someone else might not need hours.

Stripping the project down was a breeze, you’ve got to love Object Oriented design, it’s beautiful. Deploying the project was a no-brainer too, if you’ve had some experience with Git. But testing, as ever brought out the issues.

I was using Entity Framework Code First (EFCF) as my ORM and it likes to drop databases. I didn’t realize it since it’s natural for EFCF to. And for good reason too, for when you change your models. On AppHarbor, you don’t get permissions to create databases. Thus the problem.

But no fear, NuGet to the rescue. Again. Actually, community to the rescue. There’s a workaround for EFCF’s DropCreateDatabases it’s DontDropDbJustCreateTables. You can find here on NuGet. It plugs in beautifully to your application and all you need to do is enter your context name. Also, you will have to get a new database from AppHarbor since already EFCF dropped it.

Also the connection string should include a providerName otherwise, exceptions!

    <add name="connection string name"
         connectionString=";Database=dbXXXX;User ID=dbXXXX;Password=YourPassword;"
         providerName="System.Data.SqlClient" />

Blueprint CSS Framework in MVC3

Blueprint CSS Framework is a very simple and neat but oh-so-powerful CSS framework that I love to use in my MVC projects. It significantly reduces the time it takes to improve the aesthetics of a new eww-looking MVC project. Furthermore, it provides a very solid, 960px grid CSS system to build on. So, you won’t have wasted time working with it.

With the advent of the super amazingly sexy Razor view engine (read more about its super amazingly sexiness blogged about by Scott Gu and many others), using Blueprint feels even more intuitive.

So, without further ado, here are the steps to how it can be set up.

Step 1: Get it! Download the files.

Step 2: Stare at awe at the files. The files that should interest you are in the /blueprint/ directory. Of these, ie.css, print.css, screen.css are minified versions of files you will find in the /bluprint/src/ folder.

Step 3: Include ‘em. Depending on your needs, you may or may not want to include print.css. Either way, include them in _Layout.cshtml that you can find in your /Views/Shared/ folder. Of course, remember to include the files of your interest to your project. If I put put them in my /Content/ folder, for example:

<link href="@Url.Content("~/Content/screen.css")" rel="stylesheet" type="text/css" />

Step 4: Style away!

<div class="container">
    <div class="span-24 prepend-top append-bottom last">
        <h1>Some Title</h1>
    <div class="span-24 last">

You might have guessed that the CSS classes like container, prepend-top etc are being provided by Blueprint. What do they do? Exactly what they sound like. For example, the span-24 CSS class renders a column across the page 24 times span-1 which is 30px wide, by the by.

That should get you started with the framework. I’ll be writing a more extensive tutorial on Blueprint soon, so check back.

Many Choices

There are so options available to me. I could choose to learn and use any of the many languages out there. I could work on whichever framework made me feel fuzzy inside (trust me, there are some).

But this is to be an informed decision, a planned and joyous journey. Not one born of impulses. To reach a decision I have thought of the pros and cons and argued with myself,

  • Objective-C for Apple’s Cocoa API
    Pros: My machine’s native language, a beautiful one too. It’s a language that’s growing in popularity, especially with iPhones being the talk of the town. Influenced by Smalltalk and C, mothers of many languages.
    Cons: There would be a steep learning curve since I have only dabbled into it for a bit before. Available resources for learning, debugging and troubleshooting are only adequate, to put it lightly.
  • PHP on the Yii Framework
    Pros: PHP is a giant when it comes to web-based applications. The resources are abundant to learn and apply PHP. As for the Yii Framework, it’s growing, vast, versatile and dynamic, as far as I understand, it’ be a great platform to work on.
    Cons: I am relatively new with PHP, except for a few forms and files, I have done little. The learning curve would be steep, especially if I work with the Yii Framework. Even though I have worked on MVC based frameworks, I can imagine Yii being somewhat different (or maybe I am just scared of it, for some unexplained reason. I guess I have to think this through).
  • Ruby with the Ruby on Rails Framework
    Pros: Ruby is fast becoming the language of the web and agile softwares. It would be great to learn especially since this is quite different from languages I have used before.
    Cons: The learning curve would be so steep, it would probably be a straight line. I am not sure of what literature I can refer to and where I could get help. And moreover I would be at loss of a project to implement.
  • C# on the .Net Framework
    Pros: There would not be a very steep learning curve since I have worked (and working) on few projects using C# and the .Net Framework. There would be a great amount of help available from my current team members and also the online community. The library I frequent also has a sufficient amount of resources on this subject. I enjoy working with the framework because of its numerous features and ease of use.
    Cons: I fail to see the elegance of the language. Maybe I have not been exposed to it enough but I find it unattractive at times. I would have to work in a virtual environment which would reduce the efficiency of the workflow. Furthermore I would be at loss of a project to work on.

I have yet to decide but I will try my best to choose one that would be greatly enjoyable but I will be choosing soon. Even though I claimed to be thinking this all through, I would most likely be impulsive and choose one that entices me most.


Get every new post delivered to your Inbox.

Join 256 other followers