Using MVC Music Store with SQL Server 2008 (NOT Express)

Jul 13, 2012 at 3:12 PM
Edited Jul 13, 2012 at 3:14 PM

Maybe I've missed it elsewhere, but I'm trying to get the MVC Music Store tutorial to work with SQL Server 2008, NOT the express edition, NOT CE, the big ol' robust SQL Server 2008.

Just a note for Jon G: Not all of us can easily install Express or CE on our workstations at work; it would be extremely helpful to have a direct link to a path for utilizing SQL Server with the tutorial as well.  (Also, considering this will likely be the path taken in both development and production environments in enterprise situations, it's just good to know how without having to go through about three dozen extra steps, reinstalling various products, and generally ripping out what hair is left before giving up in frustration.  It's a good tutorial; PLEASE let us complete it.)

Here is the error from VS2010:

Model compatibility cannot be checked because the database does not contain model metadata. Ensure that IncludeMetadataConvention has been added to the DbModelBuilder conventions.

My provider in my connection string is System.Data.SqlClient.  I'm using Windows authentication for now, as it's in a dev environment.

Any help this direction would be appreciated!

Aug 2, 2012 at 1:23 PM

I also need to use this tutorial with SQL Server 2008.

Here are the exact steps I took to make it work.

1. Create a SQL Server 2008 database called MvcMusicStore.

2. Find the SQL script MvcMusicStore-Create in the MvcMusicStore-Assets\Data folder.

3. Edit the script and change all the table names to plural. For example, change Album to Albums, OrderDetail to OrderDetails, etc. (or you can rename the tables after they are created).

4. In SQL Server Management Studio, run the script.

5. In the project code, in global.asax change this line as follows:

            //System.Data.Entity.Database.SetInitializer(new MvcMusicStore.Models.SampleData());

6. In your web.config <connectionStrings> section, add a connection string to your new database as follow:

    <remove name="MusicStoreEntities"/>
    <add name="MusicStoreEntities" connectionString="Server=myserver;Database=MvcMusicStore;UID=myusername;Password=mypassword;" providerName="System.Data.SqlClient" />

That's what worked for me and should get you going. There are some other tweaks I had to make to get it to run properly. The jquery version was 1.4.4 in the code, but the version supplied in the scripts folder was jquery-1.5.1.js.... little things like that.

Hope that helps!


Aug 16, 2012 at 3:18 AM

I would have appreciated a note about configuring to work with a full SQL Server installation too. I'm not sure it would have spared me the ridiculous amount of time I've spent trying to get it to work. Unfortunately, I modified the web.config in the Views folder and then banged my head against the wall trying to figure out why a perfectly good connection string wasn't working. Who knew there was more than one web.config file in MVC? Not me. Anyway, it's not that hard to get working if the connection string is in the right web.config.

Oct 19, 2012 at 8:43 PM

@pfwhitworth - Did you follow the tutorial with SQL Server 2008, or did you just get the completed version running under it?

Feb 26, 2013 at 7:10 PM
Edited Feb 26, 2013 at 9:28 PM
I was able to create this db with the code by adding this in my asax...above the setInitializer
Also make sure the db is not created, this code creates the db itself for you, I had an empty db and was getting the above error.

Hope this helps someone.