JustMe2 (25) [Avatar] Offline
#1
Hi all,

I am working my way through the book and am encountering problems. As I figure out the answers, I will post them to this thread. If you have already found some and know the answers, feel free to add them to this thread.

The following were tested with EF4.0 and EF4.1

If you get the error:
"The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid." and it's on a line that ends with ": base(ConnectionString, ContainerName)" you need to add an "Application Configuration File" to your UI project. Just use the default "App.config" name. Then go to the Model project and open that projects App.config file. You should see a connection - copy the connection (with beginning/ending tags) and put it into the app.config you just added to your GUI project.

This should fix the problem.

Also, if you are getting any one of a number of weird errors when playing with files you copied from the source, check if you are calling the dump() method. If so, it has a bug. The EF works fine, but the dump() does not. The most common message you might see is:
"Exception: System.reflection.targetInvoationException: ..... " and it might include a line that says "The connection is not open." This is from the dump command.
Of course, when the dump command works, it displays a nice rendering of the Entity, but until we have a fix.....

More to come as I work through the book....
JustMe2 (25) [Avatar] Offline
#2
Re: If you are having problems
On page 76, in the example at the top, the code reads:
var result = ctx.Order.Where(o => o.Date.Year == DateTime.Now.Year);

In my case, there was no field named Date, so I got a weird error. Try using intellisence to identify the correct field. In my case, the following worked:

var result = ctx.Order.Where(o => o.OrderDate.Year == DateTime.Now.Year);

I point this out as the error message doesn't really indicate what is wrong with the statement. So now you know...

JustMe2
JustMe2 (25) [Avatar] Offline
#3
Re: If you are having problems
In regards to the prior post, you must also have the following using statement in order for the next line to work:

using System.Data.Objects;

JustMe2