Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Professional ASP.NET MVC 3
BOOK: Professional ASP.NET MVC 3
This is the forum to discuss the Wrox book Professional ASP.NET MVC 3 by Jon Galloway, Phil Haack, Brad Wilson, K. Scott Allen; ISBN: 978-1-1180-7658-3
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET MVC 3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 3rd, 2012, 01:26 AM
Authorized User
Join Date: Mar 2011
Posts: 16
Thanks: 0
Thanked 1 Time in 1 Post
Default Chapter 4, Page 81, Seeding a Database

I have created the class MusicStoreDbInitializer shown at the bottom of page 81, but where do I put it? What file does it go in?

Is it the StoreManagerController.cs file?
The Following User Says Thank You to Drogil For This Useful Post:
Old March 10th, 2012, 10:00 PM
Authorized User
Join Date: Mar 2011
Posts: 16
Thanks: 0
Thanked 1 Time in 1 Post

Ok, I think I figured it out.

I put it into StoreManagerController.cs.

Furthermore, in the Global.asax.cs file, in Application.Start(), I added this line to get it to work:

Database.SetInitializer(new MvcMusicStore1.Controllers.StoreManagerController. MusicStoreDbInitializer());

It runs without errors and works as expected.
Old May 30th, 2013, 08:39 PM
Authorized User
Join Date: Dec 2011
Posts: 26
Thanks: 1
Thanked 4 Times in 3 Posts
Default should go in models folder

Looks like this is late but FYI, it looks like it should go in the Models folder, not in the controller.

On the MVC Music Store tutorial, I found this part that indicates that the Models folder is the correct place.

Page: http://www.asp.net/mvc/tutorials/mvc...c-store-part-4

"Adding our store catalog data

We will take advantage of a feature in Entity Framework which adds “seed” data to a newly created database. This will pre-populate our store catalog with a list of Genres, Artists, and Albums. The MvcMusicStore-Assets.zip download - which included our site design files used earlier in this tutorial - has a class file with this seed data, located in a folder named Code.

Within the Code / Models folder, locate the SampleData.cs file and drop it into the Models folder in our project, as shown below."
Old August 3rd, 2013, 01:45 AM
Posts: n/a

thank you for your supportive post

Similar Threads
Thread Thread Starter Forum Replies Last Post
Error following directions on page 81. rnes BOOK: Windows Phone 7 Application Development: 24 Hour Trainer 1 January 30th, 2012 06:14 PM
Error Message on Page 81 vbboyd BOOK: Professional ASP.NET MVC 3 0 October 25th, 2011 01:54 AM
chapter 19 page 660 Cannot Create a New Database Mike_Pliskin BOOK: Beginning Microsoft Visual C# 2008 ISBN: 978-0-470-19135-4 4 September 5th, 2010 01:52 PM
Confused between onSaveInstanceState and onPause on page 81 and 82 fungi8210 BOOK: Professional Android 2 Application Development 1 March 9th, 2010 09:26 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.