View Single Post
  #9 (permalink)  
Old October 29th, 2013, 04:05 PM
Imar's Avatar
Imar Imar is offline
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Quote:
I chose generate from DB but cleared the checkbox for saving Ithe connection string in the config file
Looks like you fixed this, but yes, you want to store it in the web.config file so EF can use it.

Your DbContext and test table classes look fine; very similar to my Planet Wrox model classes.

Quote:
which has an error that says that the packages element is not declared
You can ignore that; it's just a warning when you have the package file open as it doesn't have a schema defined.
Quote:
An exception of type 'System.Data.Entity.Core.MetadataException' occurred in EntityFramework.dll but was not handled in user code
Does it provide more information? Do you see an actual, more useful error message?

Quote:
Return myquery
Try replacing that with this:

Code:
Return myquery.ToList()
EF 6 no longer works with deferred queries in a using block. Calling ToList executes the query immediately, removing the dependency from the Entities object.

Hope this helps; sounds like you're almost there.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
The Following 2 Users Say Thank You to Imar For This Useful Post:
daveharney (October 29th, 2013)