Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4.5.1 > BOOK: Professional ASP.NET MVC 5
BOOK: Professional ASP.NET MVC 5
This is the forum to discuss the Wrox book Professional ASP.NET MVC 5 by Jon Galloway, Brad Wilson, K. Scott Allen, David Matson; ISBN: 978-1-118-79475-3
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET MVC 5 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 January 17th, 2015, 04:07 AM
Registered User
Join Date: Jan 2015
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Difficulty with Chapter 4 and scaffolding

I am having issues with scaffolding and having the entity framework recognize that I need a local database created - it is assuming that a SQL database should be communicating with my code, and thus crashes.

Per the book, EF supports the creation of a local database, but I couldn't find why the DbContext Class on page 83 was not registering properly. Am I suppose to add that code because I can't find it? If I am suppose to add it, where do I add it? It's hard to explain because I don't fully understand when Entity Framework steps in and utilizes the hardcoded DbContext and MusicStoreDB.

How does the DbContext, scaffolding process, and StoreManagerController interact? Why doesn't my StoreManagerController recognize that I have a local DbContext (MusicStoreDB).
Old January 17th, 2015, 11:24 PM
Authorized User
Join Date: Dec 2011
Posts: 86
Thanks: 20
Thanked 3 Times in 3 Posts
Default Scaffold

Hi eswitzer,

As the authors seem busy elsewhere, perhaps us newbies should try to help each other. I'm certainly no expert so I can only ask the obvious question. I did the Ch4 exercises without too many problems so it should work for you also.

First, you must rebuild the project after adding any DB code. I assume you created the storemanager controller per page 85. My dialog is slightly different from page 86-87 (I use VS2013.4) but easy to relate to the book picture. I found the most important thing is to correctly select the model and context in the dialog. Did you see your context class OK at this point?
Old January 19th, 2015, 04:32 AM
Wrox Author
Join Date: Oct 2006
Posts: 36
Thanks: 1
Thanked 5 Times in 5 Posts

The code on page 83 is just an example to explain the concept. You don't need to type it in anywhere yet. The scaffolding steps beginning on page 85 (Executing The Scaffolding Template) will have you scaffold a controller, and step 5 will have you create the DbContext through the scaffolding dialog.

The database creation part is explained on page 92 and following, under "Creating Databases With The Entity Framework".
Old March 25th, 2015, 02:34 AM
Posts: n/a

I'm certainly no expert so I can only ask the obvious question. I did the Ch4 exercises without too many problems so it should work for you also.???

Similar Threads
Thread Thread Starter Forum Replies Last Post
Scaffolding 05beckga BOOK: Professional ASP.NET MVC 5 3 October 31st, 2014 12:19 PM
difficulty in installing VS 2010 murthy1951 .NET 4 and Visual Studio 2010 General Discussions 1 September 8th, 2013 01:01 PM
facing some difficulty Abdul Ghani BOOK: Ivor Horton's Beginning Java, Java 7 Edition 1 July 22nd, 2013 04:41 PM
Scaffolding problem johnisdumb BOOK: Beginning Ruby on Rails 3 June 19th, 2007 10:41 AM
Difficulty with $_SESSION mall9@hotmail.com Beginning PHP 11 March 11th, 2006 05:41 PM

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