The Grateful
Dead album cover says it all: What a Long Strange Trip It's Been.
It turned out that my project had numerous problems that caused it fail. Since I believe that my experience is probably fairly typical of newbies trying to wrap my brain around all of these pieces, I present, forthwith, these Things You Need To Know
(that took me several days to dig out of the random 3rd-party blogs, forums, tutorials, and articles that seem to have replaced any sort of coherent documentation provided by Microsoft):
- Each Entity Framework (EF) context must reside in a different database. This gem came to me from a comment in another forum. I have yet to find an article, tutorial, or (gasp!) MS documentation that tells me this. If you
look at the connection strings that I posted earlier in this thread, you'll see that I was trying to use the same Azure database for both the DefaultConnection magic and my own EF data. This was the actual problem that caused my problem.
- The "tcp:" nomenclature in the connection string is, in fact, optional. According to the gentleman who answered
this forum posting, if you omit the "tcp:" nomenclature then you incur some runtime overhead while the server (unsuccesfully) tries other connection options, such as named pipes, before deciding to use the default TCP connection. Just FYI, the easiest
way to get your Azure connection string is to right-click your Azure Deployment project in the VS Solution Explorer; Select Browse to Management Portal; Click on your database to view its dashboard, and click on Show connection strings.
- Don't forget to add MultipleActiveResultSets=True to your connection string.
- If you are using MVC 4 then do not install the ASP.NET Universal Providers.
The MVC 3 tutorials all tell you -- with no explanation why -- to install the ASP.NET Universal Providers in order to get the magic "membership" claptrap (registration, login, and logout) to work in Azure. If you use this same cookbook for an
MVC 4 app you get a runtime error that says: To call this method, the "Membership.Provider" property must be an instance of "ExtendedMembershipProvider". It turns out that MVC 3 uses the ASP.NET SQL membership providers, as described here:
http://msdn.microsoft.com/en-us/library/aa478948.aspx. The MVC 4 project template uses the new and improved SimpleMembership extension to the ASP.NET membership framework. Here
are a couple of good links for this subject:
http://blog.osbornm.com/archive/2010/07/21/using-simplemembership-with-asp.net-webpages.aspx and
http://www.asp.net/web-pages/tutorials/security/16-adding-security-and-membership.
- Your Azure project must target .Net Framework 4.0 or lower. You will run into this gotcha if you are a VS 2012 early adopter. Azure doesn't tolerate .Net Framework 4.5 (yet), which is the default framework target in VS 2012.
In Visual Studio, you must select the .Net Framework version on the first page of the New Project dialog. Converting an existing 4.5 project to 4.0 is a major pain.
And now, for your reading pleasure, I climb upon my soapbox to decry the dismal state of Microsoft documentation. Back in the day (ca. VS 2005) you could select a class or a method in your code, or a property in the Property window, press F1, and be
magically transported to reasonably complete documentation on the subject. Nowadays, it seems that F1 help is worse than useless because it forces me to stare at either a meaningless stub of documentation (if I'm that fortunate) or, worse, some totally
irrelevant high-level blurb whose relationship to the thing I've clicked on in my code is totally opaque.
So, what are my other options? The tutorials provided by the Azure and ASP.NET websites are ok as far as they go, but they provide FEW OR NO EXPLANATIONS for why they do what they do, leaving the student to "read between the lines" to figure out what's
going on in the tutorial. I wasted the better part of a week because the second tutorial on the Azure website tells me to create an MVC 3 project and then to install the ASP.NET Universal Providers. No explanation why. No warning that, hey,
MVC 4 has been out for a while now, but if you decide to use it, you should not install the Universal Providers.
Forums like this are invaluable, but gleaning scraps of knowledge one question at a time is a really tough way to learn a subject. And you need to know enough to ask the right questions...
There are a lot of good books on the fundamentals of the technology. I invested in a Safari Books Online subscription, and I use it daily. But with the pace of product changes, the books are obsolete before they are published.
It seems that the best, most up-to-date information I've stumbled across has been in the form of blogs published by Microsoft insiders. But I still don't know how to find them short of random Google searches or answers posted in forums like this.
And who has time to actually follow some MS Guru's blog in the hopes that it might contain a posting germain to a topic I'm interested in?
Sigh...