MVC 4 Beta – Single Page Application Tutorial – Gotcha
I’m currently trying out the ASP.NET MVC 4 Beta and I thought I’d give the Single Page Application tutorial a shot.
I’ve created several single page apps so far and they’re working well and people are using them successfully, but now that I’ve had some experience I look at them and wish I could rewrite them from scratch. If you look back at code you wrote six months ago and don’t think that you could do it better now then either you are perfect or you have stopped learning and are fast becoming antiquated.
So I followed the instructions, hit F5 to run the web site, typed “Tasks” in the address bar and … aaargh! An exceptions in the view and a really unhelpful error message. “System.InvalidOperationException was unhandled by user code” and “Failed to get the MetadataWorkspace for the DbContext type ‘MvcSpaApp1.Models.MvcSpaApp1Context’.” The inner exception was no better: “System.Data.ProviderIncompatibleException” and “The provider did not return a ProviderManifestToken string.”
Luckily I’ve been reading up on Entity Framework Code First, so I knew what the problem was – I didn’t have SQL Server Express running. So I started up SQL Server Express and … still didn’t work. But this time it was because I didn’t have rights to SQL Server because I was using a machine someone else set up and they had mucked up the security. Anyway, when I finally got it all sorted out the site ran without any problems.
So just be aware: YOU MUST HAVE SQL SERVER EXPRESS RUNNING and YOU MUST HAVE DATABASE AND TABLE CREATION RIGHTS.
Other than those gotchas the tutorial is good.