Thursday, July 19, 2012

Windows Azure Web Sites: Setting up a .NET MVC 4 Site using Visual Studio 2012 RC

A quick post of my experiences setting up a new .NET MVC 4 web site using the latest and greatest on Windows Azure.

Mostly it was straight forward, but I did run into some gotchas. They are documented below.



No Custom Domains

A Shared Web Site cannot currently have a custom domain name pointed to it. This is a huge limitation and disappointment.

The only way to do it is convert the site to a Reserved instance and the cheapest estimate for pricing is $50+/mon. This is astronomical compared to what you can do at other hosting solutions.

Some search revealed there might be an enhancement to Azure in the future to allow custom domain names for Shared sites. I’ve been unable to find a timeline or cost.

.NET Framework 4.5 RC Not Supported

Apparently, .NET Framework 4.5 RC is not supported by Azure. I ran into this issue because I’m running Visual Studio 2012 RC and setup the MVC 4 web project which defaults to .NET Framework 4.5. This caused errors when trying to publish the site to Azure.

To fix, I simply edited the project properties and targeted the .NET Framework 4.0. This resolved the issue.

No classes deriving from DbContext found in the current project.

I ran into a weird error when trying to run the “enable-migrations” in the Package Manager Console (see Add a Database section.) Even though my classes existed within the project the console kept returning “No classes deriving from DbContext found in the current project.”

After a little googling, I found out the MVC 4 site I had created had set itself up with .NET Framework 4.5 and defaulted the EntityFramework package to 5.0.0-rc version, which is a mismatch with the “enable-migrations” command.

To fix, I ran “Uninstall-Package EntityFramework”, then ran “Install-Package EntityFramework” and since the 5.0.0-rc is pre-release, NuGet automatically installed the released 4.3.1 version. After this was done, the “enable-migrations” command ran successfully.