Creating Music Store with VS2008 and SQL Server 2008 express

Jul 27, 2010 at 3:09 PM

First of all thanks to Jon for providing this tutorial on creating a website using the MVC design. I'm new to this way of doing things but have come from .NET 2.0 WebForms background. I wanted to create the Music Store using Visual Studio 2008 and SQL Server 2008 Express to see what the differences were between .NET 3.5 and v 4.0. I am near the end of the tutorial and it is working fine so far.

Here are some initial comments/observations if anyone is interested to hear about my experiences. :

1) Ensure the SQL Server instance is set up correctly. Firstly the home page does not explicitly say for SQL Server version 2008. Of course installing VS 2008 would also install SQL Server 2008 express by default, but as I had to put this onto my development PC I already had SQL Server 2005 standard (named instance) on it and SQL Server 2005 express.

I noticed a few people had problems setting up the database. I tried to initially install the .mdf onto my SQL Server 2005 standard version, but I got the error about"... MvcMusicStore.mdf was version 655. This server supports server version 612 and earlier...".
So to resolve this I simply installed the database software for SQL Server 2008 express. As I had already had the SQL Server 2005 management tools I didn't need to download them . Then I had to attach music store .mdf and ensure the paths were correct on the attach database screen. I had to edit the path as it contained a path that existed on Jon's PC, which obviously didn't exist on my PC.

Also I ensured my visual studio 2008 environment was configured to use my SQL Server 2008 express instance and not the default instance of SQL Server 2005 express. This was done via Tools/Options/Database Tools/Data Connections.

2) Ensure the .NET membership API is configured before moving onto Membership and Authorization p.65 onwards. As I wanted to put the default aspnetdb onto my SQL Server 2008 Express(which is a named instance) I had to use the ASP.NET SQL Server Registration Tool(aspnet__regsql.exe).

Then I had to change my web.config settings from the default SQL Server 2005 express instance to my SQL Server 2008. This was done by changing the connection string for "ApplicationServices":
connectionString="data source=yourPCName\SQLEXPRESS_2008;Integrated Security=SSPI;Initial Catalog=aspnetdb;"

This ensures the Website administration tool can be used via the ASP.NET configuration button to add users and roles etc.

2) Entity framework differences
The entity framework in v3.5 "does slightly different things" and so the code has to be changed in the relevant models. One example is that Genres is actually referenced as Genre (singular). So for example in the StoreController Index action the query is:
// Create a list of genres
  var genres = from genre in storeDB.Genre
                     select genre.Name;

EF in ver 4.0 seems cleverer and identifies objects with a plural if appropriate.

I can post a more comprehensive list if anyone is interested.

3) ShoppingCartRemoveViewModel
I think this has been mentioned before, but creating this viewmodel does not appear in the tutorial. Download the source code to obtain the file and add into your project.

I would be happy to pass on any more details about what I have learned by implementing the Music Store in the above environment.


Nov 6, 2012 at 9:06 AM


I've gotten quite far with building the MVC Music Store in VS 2008. But I've gotten stuck at the edit album on page 55. Somehow, I cannot get the foreign keys to update via a dropdownlist. Have you managed to resolve this?