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.5 > BOOK: Professional ASP.NET MVC 4
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional ASP.NET MVC 4
This is the forum to discuss the Wrox book Professional ASP.NET MVC 4 by Jon Galloway, Phil Haack, Brad Wilson, K. Scott Allen; ISBN: 978-1-118-34846-8
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET MVC 4 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 Search this Thread Display Modes
  #1 (permalink)  
Old January 8th, 2013, 05:12 AM
Authorized User
Points: 53, Level: 1
Points: 53, Level: 1 Points: 53, Level: 1 Points: 53, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2010
Posts: 12
Thanks: 1
Thanked 0 Times in 0 Posts
Default Chapter 4, p. 82 database question

The bottom of p. 82 indicates that if a database isn't already created, one will be created. As far as I can determine, a database wasn't created when I ran the project. Any suggestions?
  #2 (permalink)  
Old May 29th, 2013, 12:24 AM
Authorized User
Points: 45, Level: 1
Points: 45, Level: 1 Points: 45, Level: 1 Points: 45, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Location: Houston, TX
Posts: 11
Thanks: 2
Thanked 0 Times in 0 Posts
Send a message via AIM to rexcampbell
Default I'm encountering the same problem

Been eyeballing this section of the book for a couple weeks now. The paranoid part of me doesn't want to trudge on for fear that this will affect me later. As far as I can tell, I'm following the book directions, but they are a bit ambiguous. Not typical Wrox style directions.

I should add, I'm using VS 2012 .Net 4.5 and Entity Framework 5.
  #3 (permalink)  
Old May 30th, 2013, 02:06 PM
Authorized User
Points: 53, Level: 1
Points: 53, Level: 1 Points: 53, Level: 1 Points: 53, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2010
Posts: 12
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I found that this procedure does create a database but it's not immediately evident. If you go into the folder where your SQL Server databases are stored by default, you will see that the database has been created.
  #4 (permalink)  
Old May 30th, 2013, 02:11 PM
Authorized User
Points: 45, Level: 1
Points: 45, Level: 1 Points: 45, Level: 1 Points: 45, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Location: Houston, TX
Posts: 11
Thanks: 2
Thanked 0 Times in 0 Posts
Send a message via AIM to rexcampbell
Default

My problem is that I've checked the Models folder and nothing is there, supposedly where it should be.
  #5 (permalink)  
Old May 30th, 2013, 09:36 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 me too

I am hitting this issue too. I have tried doing the scaffolding over and over.

* I am using Visual Studio Pro 2010 with its MVC 4 add-on.
* Also, I am using the local dev database instead of the local IIS database.
* I did not put the connection string in the web.config since the book said it would do it itself.

Anyway, I have created the Album.cs, Artist.cs, and Genre.cs classes. I have then run the scaffolding as the book states. After it runs, I see the views, controller, and the MusicStoreDBContext.cs in the Models folder.

However, when I navigate to the storemanager page, I see no changes to my project. If I check the Server Explorer > Data Connections, I do not see any new database even after clicking Refresh.

I have rebuilt the project.

I have confirmed that the web.config file has this connection string:
<add name="MusicStoreDBContext" connectionString="Data Source=.\SQLEXPRESS; Initial Catalog=MusicStoreDBContext-20130530204601; Integrated Security=True; MultipleActiveResultSets=True"
providerName="System.Data.SqlClient" />

Still I am not seeing evidence of a database created.


** This creates a problem because when I create the MusicStoreDBInitializer class (in the Models folder), I get a error:
"The type or namespace name 'MusicStoreDB' could not be found (are you missing a using directive or an assembly reference?)"

- With that said, I notice that the DropCreateDatabaseAlways takes a context.
I get the error above with this code (which is from the book):
Code:
 public class MusicStoreDBInitializer : DropCreateDatabaseAlways<MusicStoreDB>
I do NOT get that error with this code
Code:
 public class MusicStoreDBInitializer : DropCreateDatabaseAlways<MusicStoreDBContext>
I notice that the text says "Name your context MusicStoreDB" but the screenshot has "MusicStoreDBContext" in the New Data Context window's field.

So, I am assuming I should use DropCreateDatabaseAlways<MusicStoreDBContext> since the file name in my Models folder is MusicStoreDBContext.cs, but I am still wondering why I am not seeing a database.

Is it possible I am looking in the wrong spot?
Is it possible I have some windows permission issue it is not throwing a flag/error about?

Last edited by Notso; May 30th, 2013 at 10:20 PM.. Reason: added
  #6 (permalink)  
Old May 31st, 2013, 12:30 AM
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 app data folder

Okay, I have confirmed that I should be looking in the App Data folder for the database and should also see it in the Server Explorer. Please let me know if anyone finds reasons the databases are not generating as expected. I believe you could do this with MVC 3 even; so, I don't think it is the fact that I am using Visual Studio 2010 with MVC 4, but maybe it is...
  #7 (permalink)  
Old May 31st, 2013, 10:51 AM
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 database present but not visible

Hello all,
It looks like in my case, there are a couple of things to note.
  1. the database created. It is just not visible in my VS 2010 Server Explorer. It is visible in the Database Explorer when I load the project in VS 2012 Express. I now have to figure out why my VS Pro 2010 does not show it.
  2. I put the DBInitializer class in the Models folder because the MVC Music Store tutorial on asp.net website puts it there. So, my code in global.asax.cs to properly seed the database needed to look like this below, which is a little different from the book.
    Code:
     Database.SetInitializer(new Models.MusicStoreDBInitializer());
  3. The book is confusing since the text does not match (as discussed above) between MusicStoreDB in the text and MusicStoreDBContext in the screenshot. I have confirmed that if you used MusicStoreDBContext like the screenshot, that is what you need to use in your code.
    So, like this in your DBInitializer class
    Code:
         public class MusicStoreDBInitializer : DropCreateDatabaseAlways<MusicStoreDBContext>
        {
            protected override void Seed(MusicStoreDBContext context)

Last edited by Notso; May 31st, 2013 at 10:53 AM.. Reason: missed something
The Following User Says Thank You to Notso For This Useful Post:
muybn (July 23rd, 2013)
  #8 (permalink)  
Old May 31st, 2013, 02:09 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 solution is to use VS 2012

Well, in case anyone else hits the issue I hit, the solution for me is:
use Visual Studio 2012 Express
  • I found this page which I thought was going to fix my issue
    http://stackoverflow.com/questions/1...erver-explorer
    I found 2 things with this
    • I had to right click on VS Pro 2010 and click Run As Administrator to do what he did
    • When I did this I could connect to the database in Server Explorer OR my local dev server could connect to it. So, I could not use the server explorer and the local dev server at the same time. When I tried, one would connect and the other would throw an error saying it could not connect to the db because another process was already using it.
  • I have also found this page, which indicates maybe I'd need to reinstall VS 2010 Pro as maybe some permission got corrupted
    http://social.msdn.microsoft.com/For...-0680f686da8c/
    but I am not certain that what that person hit is what I am encountering

Anyway, things operate fine when working with the local dev server and the database explorer at the same time in VS 2012 Express. So, my solution is just to use VS 2012 Express instead.

If anyone has suggestions on things to check/try to get VS Pro 2010 working with this project, let me know. I do prefer VS 2010.

Last edited by Notso; May 31st, 2013 at 02:09 PM.. Reason: typo
The Following User Says Thank You to Notso For This Useful Post:
  #9 (permalink)  
Old June 8th, 2013, 07:48 AM
pstviewer
Guest
 
Posts: n/a
Default

I tried it but this data not working properly can you tell me other alternative solution??
  #10 (permalink)  
Old June 17th, 2013, 04:57 PM
Authorized User
Points: 53, Level: 1
Points: 53, Level: 1 Points: 53, Level: 1 Points: 53, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2010
Posts: 12
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I agree that this chapter could have been a little clearer on some items. The database doesn't show up in the Server Explorer or in the App_Data folder. I found that it was created on my computer by going to C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL; and I am also able to open and manipulate the database with the SQL Server Management Studio.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Errata for Chapter 4 - Project EmptyApp, Page 82 weimenglee BOOK: Beginning iOS 5 Application Development 3 April 20th, 2012 05:03 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
Database Question rose77 Access 0 January 9th, 2005 02:14 PM
Database question! Calibus Classic ASP Databases 3 August 17th, 2004 05:23 PM
Exercise ch2, page 82 ssr All Other Wrox Books 2 September 10th, 2003 03:42 AM



All times are GMT -4. The time now is 10:05 AM.


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