MVC Music Store Updates - MVC 3 Tools Update Features, Scaffolding, Save Points, VB.NET Code
The latest drop of the Mvc Music Store tutorial cover the ASP.NET MVC 3 Tools Update, Scaffolding, Entity Framework Code First, SQL Server CE, and more. Additionally, this drop includes a VB.NET translation of the finished project as well as save points how the code should look when you complete each section.
What's in the ASP.NET MVC 3 Tools Update
The ASP.NET MVC 3 Tools Update doesn't change anything in the ASP.NET MVC 3 runtime. If you've got the ASP.NET MVC 3 RTM (as released January 13) installed and I've got the ASP.NET MVC 3 Tools Update installed, we can both happily work against and deploy the same code without any issues at all. As the name (hopefully) suggests, this update really includes two main changes:
- Updated Visual Studio tooling to take advantage of the above features. An obvious example is the new controller dialog, which takes advantage of the new MvcScaffolding package to generate views for the default actions as well.
For more information about the ASP.NET MVC 3 Tools Update, see Scott Guthrie's post (and the included links).
Where to get the updated tutorial
As always, you can download the latest release of the Mvc Music Store tutorial - PDF document and code - from http://mvcmusicstore.codeplex.com. You can also read the content online starting at http://www.asp.net/mvc/tutorials/mvc-music-store-part-1
New Feature: VB.NET Code
This release includes a translation of the the completed project code to VB.NET (thanks, Lisa Feigenbaum and team!). We've had a lot of VB.NET developers follow the tutorial in the past, converting each step to VB.NET as they went. Hopefully having a working sample of the completed project in VB.NET will make that a lot easier. VB.NET dev's, I'd be happy for any feedback on this!
Note: One thing that was interesting to me here - as a dev who started with VB "classic" a long time ago but transitioned to C# when I started .NET development - was the difference in how namespaces are handled and used in VB.NET vs. C#. We matched the namespacing style for VB.NET project and item templates, so the finished code should look as it would if you followed the tutorial steps starting with File / New / VB / Empty ASP.NET MVC 3 Application.
New Feature: Save Points
I always make several runs through the tutorial each time I update it to make sure the code is accurate, compiles at each step, etc. I've been capturing save points as I complete each chapter for my own sanity and efficiency, and for this release I'm publishing those as well. There's an optional zip download that includes a separate copy of the application as it looks at the completion of each major chapter. Since the first chapter is an overview of the install and file / new project experience, the snapshots start at Chapter 2:
I anticipate this will be useful for (at least) two scenarios:
- If you are having trouble with a section, you can grab the working code for the nearest chapter save point and compare against your code
- This makes it easier to skip sections, jump in from a previous release of the tutorial, join at any point, use individual chapters in a lab or class environment, etc.
Changes related to the MVC 3 Tools Update
I published another big update for the MVC Music Store tutorial during MIX11 to coincide with the ASP.NET MVC 3 Tools Update release. It was a pretty major rewrite, so I published it as a Beta. Since then I've corrected and clarified a few things in the tutorial document (no code changes) and upgraded to a stable release.
The biggest changes to the tutorial were:
- Converting the Store Manager (Admin) section to use the new scaffolding system
- Switching data access to use SQL Server CE and Entity Framework Code First
- Explaining software prerequisites and installation
Changing the Store Manager to use Scaffolding
This section of the tutorial focuses on building out admin create/read/update/delete support for the albums carried in the music store. Previously, the tutorial had you create the controller, write the required code, and manually create each view. The new update leverages the scaffolding system to generate the majority of this code via scaffolding, then explains how the generated code works. The end result is basically identical, but since I removed a lot of repetitive, manual steps (now add another view, following the same steps as the previous ones, but naming this one Edit...), I was able to add a lot more explanatory material and still drop the page count by about 20 pages.
I think the end result is good here:
- The code is as good - frankly, in some ways, the generated code is a little better
- I don't think we really lost any useful learning opportunities, since a lot of the code that was being typed in previous tutorials was repetitive
- There was more opportunity to explain what the code was doing and why
- By learning about scaffolding, the transition to leveraging some more advanced patterns - like using repositories - is simpler, since the MvcScaffolding package includes a repository-based scaffolder
Switching data access to use SQL Server CE
A large percentage of the support issues for previous releases have been due to data access. Like many .NET developers, I have a love / hate / really hate relationship with SQL Server Express. It's one of those technologies that either works transparently, or doesn't work for some bizarre reason that's really painful to troubleshoot. It was heartbreaking to try to help developers through previous versions of the tutorial at Web Camp events who couldn't get SQL Server Express running on their laptop for some reason or another. It generally works pretty well for me, but there are times where it's given me problems, as well. SQL Server Compact provides a much simpler getting started experience, where you just want your data to be persisted without troubleshooting service permissions and installation issues.
The tutorial materials still include an MDF file and SQL Scripts in case you want to use SQL Server Express or a dedicated SQL Server instance, but I think the SQL Server Compact experience should work a lot better for most people.
Explaining software prerequisites and installation
This tutorial includes more information up-front about what you need installed and how to get it. Again, some of this is based on user questions and issues from the forums, in person, etc. The first chapter now includes information about how to install the required software - either via Web Platform Installer (recommended) or via individual installers if you prefer.
As always, please leave any comments or suggestions on the project site at http://mvcmusicstore.codeplex.com. Use the discussion list if you need help, and use the issues list if you've got a suggestion or bug report.