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 2
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional ASP.NET MVC 2
This is the forum to discuss the Wrox book Professional ASP.NET MVC 2 by Jon Galloway, Scott Hanselman, Phil Haack, Scott Guthrie, Rob Conery; ISBN: Professional ASP.NET MVC 2
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET MVC 2 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 October 22nd, 2010, 01:52 PM
Registered User
 
Join Date: Oct 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default p. 49 - EntityContainer name not found error

Hello,

Probably an easy question, but I'm definitely new to this, so here goes.

Trying to execute the request shown on p. 49 of the text, where you go to the URL http://localhost:44593/dinners/details/9999. I've double-checked my code against the sample source and the text and can't figure out what's wrong, but I'm getting this error:

"The specified default EntityContainer name 'NerdDinnerEntities' could not be found in the mapping and metadata information.
Parameter name: defaultContainerName"

in this section of code:

Code:
Line 37:         /// Initializes a new NerdDinnerEntities object using the connection string found in the 'NerdDinnerEntities' section of the application configuration file.
Line 38:         /// </summary>
Line 39:         public NerdDinnerEntities() : base("name=NerdDinnerEntities", "NerdDinnerEntities")
Line 40:         {
Line 41:             this.ContextOptions.LazyLoadingEnabled = true;
I get into the constructor for DinnersController, and from there into DinnerRepository, but my constructor for NerdDinnerEntities fails...

My SQL Server database is up and running, I can browse the tables and see the data I've entered.

Any ideas?

Thanks,
Tony
  #2 (permalink)  
Old October 22nd, 2010, 04:28 PM
Friend of Wrox
Points: 539, Level: 8
Points: 539, Level: 8 Points: 539, Level: 8 Points: 539, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2010
Location: Seattle
Posts: 106
Thanks: 1
Thanked 17 Times in 17 Posts
Default

I'm guessing you may have moved NerdDinner.edmx from it's original location.

Take a look at your Web.Config. Search for NerdDinnerEntities. You may need to adjust namespace. I created my NerdDinner.edmx in the Models folder. My connection string in Web.Config looks like this:

Code:
    <add name="NerdDinnerEntities" connectionString="metadata=res://*/Models.NerdDinner.csdl|res://*/Models.NerdDinner.ssdl|res://*/Models.NerdDinner.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\NerdDinner.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
Also check the namespace in NerdDinner.Designer.cs. It should match.
Code:
namespace NerdDinner.Models

Last edited by flyinhawaiian; October 22nd, 2010 at 04:34 PM..
  #3 (permalink)  
Old October 22nd, 2010, 04:44 PM
Friend of Wrox
Points: 539, Level: 8
Points: 539, Level: 8 Points: 539, Level: 8 Points: 539, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2010
Location: Seattle
Posts: 106
Thanks: 1
Thanked 17 Times in 17 Posts
Default

Also note on Page 24, figure 1-46. The Model Namespace is shown as "NerdDinner.Models". (I used this one).

However, VS 2010 actually defaults it to "NerdDinnerModel" (w/o the period and singular).
  #4 (permalink)  
Old October 25th, 2010, 04:21 PM
Registered User
 
Join Date: Oct 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, cleaning up the .edmx file got me there. I forgot that I had mistakenly gone through the steps to create NerdDinnerEntities twice, and deleted the first one. The one left was named NerdDinnerEntities1 throughout, and I didn't catch every instance where that was used throughout the project. Cleaning up the .cs file was only half of it, I had to clean the .edmx as well.

Tony
 


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
Correction to page 49 SeanDunn BOOK: Beginning Microsoft Visual C# 2008 ISBN: 978-0-470-19135-4 3 January 3rd, 2010 01:00 AM
Subscript out of range: '[number: 49]' hameed Classic ASP Databases 2 August 5th, 2004 08:32 AM
Config Apache 2.0.49 for PHP4.3.5Win32 Domonsura BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 July 22nd, 2004 04:32 AM



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


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