|
 |
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 .
|
 |
|
|

November 1st, 2013, 05:19 AM
|
Registered User
|
|
Join Date: Oct 2013
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Professional ASp.NEt MVC 4 Woes
Yep, I'm having awful problems with this book too. page 78 creating a StoreManagerController, when selecting New Data Context, ok and Add, VS throws an error saying that the fields have no primary key!!! I have another post here somewhere with the EXACT error being thrown. I was under the impression that Entity Framework creates the database by Modelling the Code in the Classes, either this is false or the book is wrong (either by being badly written or badly formatted by the publisher) and a complete and utter waste of time and more importantly money.
I bought the book hoping it would fare better than the online version which was also frought with bad formatting, e.g. telling the user to run the application and expect results that weren't possible because the code to facilitate this hadn't yet been presented to the student. What is the point of asking someone to do something in part 2 when the code required to do so doesn't appear until part 4?
Don't they have proof readers working for the publisher to ensure the text is correct or not?
|

November 1st, 2013, 07:17 AM
|
Authorized User
|
|
Join Date: Jun 2013
Location: St.Petersburg, Russia
Posts: 36
Thanks: 1
Thanked 4 Times in 4 Posts
|
|
I remember that I did it exactly as the book says and it worked fine for me.
If EF cannot figure out Primary Keys of your fields, may be you should take a look at your model classes. You can either use "naming conventions" - fields with "id" in their names, or apply attributes - [Key]
Code:
public class Book
{
[Key]
public string ISBN { get; set; }
And, guys, I do not want to offend anyone, but the book is in "Professional"-series. The readers are supposed to have certain experience in .NET and in Web-programming. The book does not take you by the hand and goes exactly "step by step" as books for beginners do.
If you find it difficult to follow its tempo, may be you should start with grasping the basics of ASP.NET MVC. On asp.net/mvc website there are FREE Pluralsight videos by Scott Allen. Take some time to watch them and I think you will find the book easier to follow afterwards.
|
The Following User Says Thank You to Oleg Kolpashchikov For This Useful Post:
|
|

November 1st, 2013, 08:15 AM
|
Registered User
|
|
Join Date: Oct 2013
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
thanks
Hi, thanks for the reply, have gotten a little further now, there must of been a glitch somewhere. I scrapped my project and started again from scratch, it seems to be working a little better. But I still maintain that the book is NOT written as well as it should be. However, I will persevere, it's the only way to learn :)
|

November 1st, 2013, 12:03 PM
|
Registered User
|
|
Join Date: Oct 2013
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
more ASP.Net MVC 4 woes
having gotten up to page 97 I find the methods given in "To Get or to Post" nonsensical. It's all well and good giving code examples for a "form action" and then an "ActionResult", but this is not going to work when the author (or printer/publisher) has omitted to tell the reader the vital part of instantiating the following in the the HomeController:
MvcMusicStoreDbContext _storeDb = new MvcMusicStoreDbContext();
Without the above code placed in the HomeController.cs class the application fails and there is no mention of it in the book! The only thing I can say I have actually learned thus far, is to never buy another book published by Wrox.
How is the reader supposed to know this? They cannot pluck this out of mid air. A shockingly bad example by any standards, no wonder so many potential coders give up the ghost when they are presented with such poor examples and at great expense to boot, these books do not come cheaply.
|

November 1st, 2013, 03:37 PM
|
Authorized User
|
|
Join Date: Jun 2013
Location: St.Petersburg, Russia
Posts: 36
Thanks: 1
Thanked 4 Times in 4 Posts
|
|
The code snippet on page 97 shows only the "Search"-method of the HomeController. And it's an example for the discussion of whether to use HTTP GET or HTTP POST.
Normally you should create DBcontext in the controller, not inside the action. And that's why it's not the snippet.
And the action is SO OBVIOUSLY using the storeDB as dbContext by LINQ-query.
Go back to Chapter 4 on models and read again. Or better yet, learn some basics of Entity Framework and LINQ. These technologies are separate from ASP.NET MVC and are not supposed to be explained in every little detail.
|
Thread Tools |
Search this Thread |
|
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |
All times are GMT -4. The time now is 12:24 PM.
|