Introducing the MVC Music Store - MVC 2 Sample Application and Tutorial

A couple weeks ago we did a soft release of a new ASP.NET MVC 2 Tutorial and Sample Application I’ve been working on over the past few months, the MVC Music Store. The source code and an 80 page tutorial are available on CodePlex. I’m also working on a video tutorial series for the ASP.NET website which will walk through building the application. After that, it’s time to talk about a feature length film and a worldwide MVC Music Store On Ice tour, but the plans aren’t completely set just yet.

MVC Music Store

MVC Music Store - Shopping Cart

MVC Music Store - Admin

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.

Who is this for?

This tutorial is mostly written for beginners to ASP.NET MVC, including folks who are kind of new to web development. We already have a few tutorials out there at the intermediate to advanced developer level (Nerd Dinner, MVC Storefront) if you’re looking for something more advanced, but if you want to start with the basics of how ASP.NET MVC works before diving into repositories and IoC and TDD, this is a great place to get started.

However, I think it’s also pretty useful if you’ve got some experience with ASP.NET MVC 1.0 but want to get a look at using some of the new features in ASP.NET MVC 2, especially model validation.

What’s it cover?

Store features:

  • Store browse
  • Shopping cart
  • Checkout
  • Membership and registration
  • Basic administration (add and edit albums)

Tutorial covers:

  • ASP.NET MVC Basics
    • Controllers
    • Views
    • Models and ViewModels
  • Data access using Entity Framework 4
  • Model Validation
  • Editor and Display Templates
  • Use of ASP.NET Membership system
  • Client-side enhancements
    • Client-side validation
    • AJAX update showing both Ajax.ActionLink and jQuery

How’s the code?

I think this is a great tutorial sample, and I’m really proud of it. I spent a lot of time on it, and I had several reviews with Scott Guthrie and Scott Hanselman, as well as Phil Haack and Brad Wilson from the ASP.NET team. I’m hugely thankful to all of them for their input and patience, but of course I’ll take responsibility for any errors or killed kittens.

This is a beginner tutorial, so the code focuses on communicating how ASP.NET MVC works. There are no dependencies, and things are written using a minimum of code and complexity. If you do see something that makes you angry or sad please let me know, but keep in mind that we’re not trying to build an enterprise store system here. As it is, the tutorial is 80 pages long, so I really tried to keep as much out as possible and focus on the basics.

Where next?

I’ve already gotten some good feedback on the discussion forum and at the Toronto Web Camp, where we used it as lab, so I’ll be updating the document and tutorial to get to a 1.0 release.

I’m working on a video series for the ASP.NET website.

I’ve also heard that people are interested in advanced, real-world scenarios, so that’s something I’ll be looking at next. Please let me know if you have any thoughts or requests there.

Tailspin Spyworks Web Forms Sample

If you haven’t seen it, check out Joe Stagner’s Tailspin Spyworks sample - an update of the popular iBuySpy application for ASP.NET 4 with all the new goodies.

14 Comments

  • I did this tutorial at Webcamp Toronto this past weekend. I found this to be very helpful in what you can do. In capabilities and learning this was as helpful as the nerd dinner was in getting into MVC 1.0.

  • @mike - Great, good to hear it!

  • This is a very nice little project - thanks for taking the time to put it together. - Eric

  • Jon,
    I got lost at page 30 of your guide. I'm getting red squiggly lines. I'm also not clear where between pages 29 and 32 I'm supposed to press F5 and compile to see if everything is working. You might want to add a few checkpoints.

    Now I'm off to go figure out why I'm getting errors...

  • A few other quick things:
    On page 43 you need to include: using MvcMusicStore.Models;

    On page 47, for clarity you might want to mention that you're adding the to the storemanager view.

    On page 50, you need to include: using MvcMusicStore.ViewModels;

  • Just returning to work on the lab. I'm confused about the Album.ascx on page 53. Am I supposed to create this Album.ascx?

  • This is the best into to ASP.MVC 2 and EF4 out there - exactly what i needed! Thanks for the effort you've put it. Had to link to this :) Everyone should know about it

  • This is great! Thanks. Is the music store online like nerddinner.com?

  • Cant get browse genre items displayed in MVC Music Store application.
    Using Windows 7, when writting code for store controller </Select from genres: and not right.
    Says only assignment, call, increment, decrement and new object expressions can be used as a statem

  • This tutorial is amazing. Very good work. Of course it helps that MVC2 in itself is quite amazing.

    I read about it earlier, but am only now getting my hands dirty. Thanks to this tutorial, the part about getting my hands dirty is purely figuratively speaking :)

  • Write very well, there are some others that resonate.

  • I was halfway through this tutorial when I came back from lunch to find that it is now for MVC 3, and not MVC 2. This means that all the views are different, as it uses the ASP.Net Web Pages “Razor” Syntax

    Are the old MVC 2 tutorials available somewhere? It was all very confusing for a while. I felt like I'd slipped into a parallel dimension!

  • Hi Jon,

    The MVCMusicStore (MVC 2 ) doesn't work at all. I have changed the connection string to my local SQLExpress but still can not open the adatabase and there is error on return storeDB.Albums
    .OrderByDescending(a => a.OrderDetails.Count())
    .Take(count)
    .ToList();

  • Your post informative.It really be a growing area to see this year. As you say, the comments to keep the conversation always so interesting to visit his site.What great information thanks for sharing this will help me greatly in my learning.

Comments have been disabled for this content.