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

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.

Published Wednesday, May 12, 2010 9:04 AM by Jon Galloway

Comments

# re: Introducing the MVC Music Store - MVC 2 Sample Application and Tutorial

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.

Wednesday, May 12, 2010 1:26 PM by mike johnson

# re: Introducing the MVC Music Store - MVC 2 Sample Application and Tutorial

@mike - Great, good to hear it!

Wednesday, May 12, 2010 6:18 PM by Jon Galloway

# re: Introducing the MVC Music Store - MVC 2 Sample Application and Tutorial

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

Friday, May 14, 2010 7:56 PM by Eric N

# re: Introducing the MVC Music Store - MVC 2 Sample Application and Tutorial

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...

Monday, May 17, 2010 5:24 PM by Dan Cavita

# re: Introducing the MVC Music Store - MVC 2 Sample Application and Tutorial

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 <%@ Import Namespace="MvcMusicStore.Helpers" %> to the storemanager view.

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

Monday, May 17, 2010 6:57 PM by Dan Cavita

# re: Introducing the MVC Music Store - MVC 2 Sample Application and Tutorial

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?

Tuesday, May 18, 2010 12:31 PM by Dan Cavita

# re: Introducing the MVC Music Store - MVC 2 Sample Application and Tutorial

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

Tuesday, June 1, 2010 6:07 AM by British Developer

# re: Introducing the MVC Music Store - MVC 2 Sample Application and Tutorial

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

Friday, August 6, 2010 1:54 PM by Jim

# re: Introducing the MVC Music Store - MVC 2 Sample Application and Tutorial

Cant get browse genre items displayed in MVC Music Store application.

Using Windows 7, when writting code for store controller </Select from <%: Model.NumberofGenres%>genres:</> and <%genrenames%> not right.

Says only assignment, call, increment, decrement and new object expressions can be used as a statem

Wednesday, August 25, 2010 10:43 AM by markt264

# re: Introducing the MVC Music Store - MVC 2 Sample Application and Tutorial

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 :)

Friday, September 3, 2010 1:05 PM by Niels Brinch

# re: Introducing the MVC Music Store - MVC 2 Sample Application and Tutorial

Write very well, there are some others that resonate.

Monday, November 29, 2010 1:05 AM by Coach Outlet

# re: Introducing the MVC Music Store - MVC 2 Sample Application and Tutorial

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!

Thursday, January 13, 2011 5:12 PM by Paul

# re: Introducing the MVC Music Store - MVC 2 Sample Application and Tutorial

I'm getting a SQLException, when trying to generte the Entity Framework model. I'm using VS 2010, SQL Express 2008 R2, Win 7. Selected teh mdb in another directory and VS 2010 automatically copied it into App_Data.

Friday, January 21, 2011 1:50 PM by Ralph Compton

# re: Introducing the MVC Music Store - MVC 2 Sample Application and Tutorial

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();

Sunday, April 17, 2011 10:42 AM by behrouzbk

# re: Introducing the MVC Music Store - MVC 2 Sample Application and Tutorial

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.

Thursday, April 5, 2012 3:33 PM by Catering in Rochester NY