Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Professional ASP.NET MVC 3
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 3rd, 2012, 01:26 AM
Authorized User
Points: 89, Level: 1
Points: 89, Level: 1 Points: 89, Level: 1 Points: 89, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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:
  #2 (permalink)  
Old March 10th, 2012, 10:00 PM
Authorized User
Points: 89, Level: 1
Points: 89, Level: 1 Points: 89, Level: 1 Points: 89, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2011
Posts: 16
Thanks: 0
Thanked 1 Time in 1 Post
Default

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.
  #3 (permalink)  
Old May 30th, 2013, 09:39 PM
Authorized User
Points: 148, Level: 2
Points: 148, Level: 2 Points: 148, Level: 2 Points: 148, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Posts: 26
Thanks: 1
Thanked 4 Times in 3 Posts
Default should go in models folder

Hello,
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."
  #4 (permalink)  
Old August 3rd, 2013, 02:45 AM
Staceysmith
Guest
 
Posts: n/a
Default

thank you for your supportive post
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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



All times are GMT -4. The time now is 03:36 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.