 |
BOOK: Beginning ASP.NET 4 : in C# and VB
 | This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB 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
|
|
|
|
|

December 23rd, 2012, 03:36 PM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Chapter 14: Entity Model Code WILL NOT WORK!
Hi Imar, I hope you still check this forum out...
I picked up a copy of your book and I've been working through some of the exercises here and there. However, I am having a really hard time implementing the ADO Entity Object Model code in chapter 14.
I am using Visual Studio Web Developer Express 2012, and I have tried creating the project in ASP.NET 4 and 4.5 but to no avail. I can successfully connect to the database and create the entity model. However, I can't create a new object; the code keeps rejecting it saying I am missing a namespace.
I did quite a bit of Google-fu and found that I need to change the code generation strategy to Default (from none; your book doesn't mention to do this...) but now I am getting compiling errors saying that I am missing references in my web.config file.
I am ready to pull my hair out!
What the heck am I doing wrong?!
Thanks,
Drew
|
|

December 23rd, 2012, 03:47 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
This book targets ASP.NET 4 and Visual Studio 2010 where the behavior was quite different and the generated code targets ObjectContext. In VS 2012 the code strategy is different indeed and generates code that targets DbContext. My book doesn't mention any of this as VS 2012 and it's new behavior didn't exist yet by the time it was published ;-)
What works for me is to delete the *.tt files that VS creates and then set the strategy to Default. This way, it ends up the same as in VS 2010. Fore more details; http://msdn.microsoft.com/en-us/data/jj556581
Cheers,
Imar
|
|
The Following User Says Thank You to Imar For This Useful Post:
|
|
|

December 23rd, 2012, 04:28 PM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Imar,
Just tried that; I am still getting two odd behaviors:
The first one I get is when I try to run the project:
Code:
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Could not load type 'System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider'.
Secondly, I am still not able to access the namespace in the application; I just cannot get that namespace to recognize!
Am I better off trying to do this in ASP.NET 4 and VS 2010 instead?
So frustrating!
|
|

December 23rd, 2012, 04:48 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Make sure your web.config has references to System.Data.Entity like this:
Code:
<compilation debug="false" targetFramework="4.0">
<assemblies>
<add assembly="System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
<buildProviders>
<add extension=".edmx" type="System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider" />
</buildProviders>
</compilation>
I just opened the full code for Chapter 13 in VS 2012. This code has the aforementioned references. I then added a model and then I can instantiate the context and other classes just fine.,
Cheers,
Imar
|
|

February 28th, 2013, 07:32 AM
|
|
Authorized User
|
|
Join Date: May 2012
Posts: 26
Thanks: 0
Thanked 1 Time in 1 Post
|
|
I am trying to use the information from this chapter on a different website that I am creating, and I have managed to get it working, however the All.aspx page is ignoring my master page.
Do you know why this may be?
Thanks
P.S. I'm using visual studio express 2012
|
|

February 28th, 2013, 07:43 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
Is this related to the post you're answering to? If so, can you describe how? If not, please post new topics like this as a new thread here on P2P.
That said: you'll need to post the relevant code for that page and the master page so we can take a look...
Cheers,
Imar
|
|

February 28th, 2013, 07:48 AM
|
|
Authorized User
|
|
Join Date: May 2012
Posts: 26
Thanks: 0
Thanked 1 Time in 1 Post
|
|
I thought it was relevant, but I suppose that is is a little bit of a tangent.
I'll create a new post
|
|
 |
|