Learn ASP.NET MVC 3 with the MVC Music Store tutorial
Now is a great time to learn ASP.NET MVC. ASP.NET MVC 3 combined with NuGet have made the start-to-finish process of building out a website a lot simpler. If you’d like to see what’s new in ASP.NET MVC 3 and NuGet, or if you’ve never done ASP.NET MVC development, I think the MVC Music Store is a great place to start.
The first release of MVC Music Store came out last May. I wrapped up a major update last October, and released a full rewrite on the day MVC 3 went live. Here’s an overview of what’s changed since the previous release:
- All views are using the new Razor engine
- Views demonstrate the use of Razor Layouts (rather than the MasterPages in the previous version)
- Data access using Entity Framework Code-First (rather than the EF Database First approach in the previous releases)
- Use of NuGet to install and configure the Entity Framework Code-First library
- Added coverage of ViewBag, so the tutorial demonstrates use of both ViewBag and ViewModels to pass view-specific information
- Using jQuery and the MVC 3 unobtrusive Ajax features for all client side scripting (previously used both jQuery and Microsoft AJAX)
- Fixed some bugs and tricky parts based on thousands of previous downloads
You can read through the tutorial online on the ASP.NET website starting here: http://www.asp.net/mvc/tutorials/mvc-music-store-part-1
You can download all the materials for the tutorial from http://mvcmusicstore.codeplex.com, including:
- 150 page PDF e-book tutorial with tons of screenshots and code samples
- Assets to build out a working site – images, CSS, and a database stocked with music
- The completed project so you can check against it if you’re having trouble
- Tons and tons of screenshots to guide you through every step
The tutorial walks through the following topics:
- Overview and File->New Project
- Views (using Razor)
- Models and Data Access (using Entity Framework Code-First, installed via NuGet)
- Edit Forms and Templating
- Using Data Annotations for Model Validation
- Membership and Authorization
- Shopping Cart with Ajax Updates
- Registration and Checkout
- Final Updates to Navigation and Site Design, Conclusion
As before, everything’s under friendly licenses - the source is available under Ms-PL license, and the tutorial is under Creative Commons Attribution license. The data for the application is based on the Chinook database, which is also under Ms-PL license. The code repository uses Mercurial, and pull requests are welcome.
If you have comments or run into trouble, the best place to get help is on the Discussions board for the project on CodePlex. If you problems with the code that you think need to be fixed, please use the Issue Tracker on CodePlex – that drove a lot of the changes features for this release.
If you’re looking for a shorter, simpler tutorial to get started, check out the introductory MVC Movie Application tutorial, with code samples in both C# and VB.NET.