MVC MUSIC Store DB foreign Key problem...

Jan 17, 2011 at 1:04 AM
Edited Jan 17, 2011 at 1:34 PM


Hi Guys,

I got a question about foreign key when "importing" the db into visual studio.


my development environment:

SQL 2005/2008/2008R2

Visual Studio 2008 ASP.NET MVC 2 with .Net framework 3.5 SP1

was following the MVC music store V1.0


in the tutorial pdf, page 50, it says when we creating the "Entity Data Model" at the last stage, we should select "Include foreign key columns in the model.

however, i am using VS2008 and when at this stage there is no such foreign key option to choose.

but i still clicked finish and got the ER diagram like this

plz notice that inside the red circle, it should contain (AlbumId, GenreId, ArtistId, Title, Price, AlbumArtURL)

but my model is missing GenreId and ArtistId.

how do you deal with it?

I encountered a problem later when the i creating edit form and need to use something like [[[[<%= Html.LabelFor(model => model.GenreId) %>]]]]] it is not working.


so i need the GenreId and ArtistId to appear in the Album. i guess it is about the foreign key problem...

do you know how to solve it?


Thanks a lot!!!



Mar 21, 2011 at 8:42 AM

I got also struck here. Does anyone have answer?

Apr 1, 2011 at 5:18 AM

It appears that you both are trying to follow the old version of the tutorial. It would be better if you would download the new version as it would be easier to help you from that one. The tutorial and project were both updated around the time of the question by @jimhe and I do not have the original version available.

Apr 6, 2011 at 10:23 PM

@madisonjames is right - you should use the v2 release.