Errata

Programming Entity Framework

Errata for Programming Entity Framework

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date submitted Date corrected
Other Digital Version
x
Figure 9-6

On topic 9.3. Object Materialization it is said that EntityClient retrieves the database result into an EntityDataReader and then it passes it to the Object Services.

On figure 9-6 (The EntityClient providing the command execution functions for an ObjectQuery)

This figure is showing the result from the database going straight from the DataBase provider to the Object Services skipping the EntityClient.

Isn't the result supposed to pass by the EntityClient first before reaching the Object Services?

Note from the Author or Editor:
Not sure at what stage in the game this image changed. Too late for 2nd printing. Get a new image from me when we go to next printing

Eduardo Coelho  May 21, 2009 
Ch15
Right below Example 15-1

Should be ORDER BY BAModel.FullNameReverse(c) (with space between ORDER and BY); not ORDERBY BAModel.FullNameReverse(c) for Entity SQL

This comment is for EF Second Edition (EF4)

Note from the Author or Editor:
please make the suggested correction

Felix  Aug 22, 2010 
Printed
Page xxxiv
1st paragraph

The link cited for the book web page,

http://oreilly.com/catalog/9780596807269

does not lead to a list of errata; it is redirected to a shop.oreilly.com page. I had to search for the errata, and found the list at:

oreilly.com/catalog/errata.csp?isbn=9780596520281

Note from the Author or Editor:
thanks. it's been quite a few years so maybe they broke the link.

Anonymous  Oct 14, 2013 
Printed
Page 1
2nd paragraph

The sentence that reads:
"...as part of Visual Studio Service Pack 1 and .NET Service Pack 1,...

Should read:

...as part of Visual Studio 2008 Service Pack 1 and .NET Service Pack 1,...

Since it is that specific version of Visual Studio that is supported.

Note from the Author or Editor:
as part of Visual Studio 2008 Service Pack 1 and .NET 3.5 Service Pack 1,...

Javier Estrada  Apr 02, 2009  Sep 01, 2009
21.3
Last sample in the section

Not so much an error, but would be very useful if the following could be included above the sample for your ListProvider (21.3)

using System.Collections;
using System.Collections.Generic;

Leaving out System.Collections (as I did) results in a "Using the generic type System.Collections.Generic.IList<T> requires 1 type arguments". Although this may seem minor, I spent a while trying to figure this out, and it's a great sample, so would hate to see others give up trying to implement this...

Note from the Author or Editor:
I'm working on 2nd edition of book and being more explicit about adding namespace delcarations since this seems not to have been so obvious to a number of readers. Thanks for validating this decision.

Ren Hammington  Sep 02, 2009 
Printed
Page 31
2nd paragraph from bottom

The instructions for opening the edmx file with the XML Editor do not work with Visual Basic 2010 Express (build 10.0.30319.1.) There is no right click option for "Open With" in the Solution Explorer. Instead the user will need to go to File -> Open File and then select "Open With" from the Open ComboBox in the FileOpen dialog.

Note from the Author or Editor:
taking this for granted since I don't have the express version...
please add to end of 2nd to last paragraph:

"If using one of the Visual Studio Express versions, you will need to open the raw XML from the File menu as there is no Open With option on the model's context menu."

Mark  Oct 10, 2010 
Printed
Page 43
2nd Line

-The name of the EntityContainer is "dbo," .....

Should be:
-The name of the EntityContainer is "ProgrammingEFDB1ModelStoreContainer" .....

Note from the Author or Editor:
In addition to replacing dbo with ProgrammingEFDB1ModelStoreContainer, please remove the word "schema" from the sentence. It should read:

The name of the EntityContainer is ?ProgrammingEFDB1ModelStoreContainer,? which was derived from the database name.

Kam_UK  Feb 28, 2009  May 01, 2009
Printed
Page 44
2nd line of the last paragraph

...without a reference to a row in the People table. ...
Should be:
...without a reference to a row in the Contact table. ...

Kam_UK  Feb 28, 2009  May 01, 2009
PDF
Page 48
2nd and 3rd paragraph

Maybe I missed something, but here (at the top of 48):

Figure 2-20 displays the MappingAssociation for the CSDL?s FK_Contact_People association
in the Designer. You can open this by right-clicking on an association in the
Designer and selecting Table Mapping.


Shouldn't that be FK_Contact_Address instead of FK_Contact_People ? Not sure where people came from. This also happens again in the next paragraph. Great book by the way!

Note from the Author or Editor:
Yes, should be FK_Contact_Address.

Josh Williams  Feb 28, 2009  May 01, 2009
Printed
Page 52
Bottom (Under Figure 3.3)

2nd Edition of Book - EF4

I am not able to navigate to Visual Studio's Class Designer View to see what is in Figure 3-4 or anything else that the book describes through page 53. I cannot see any classes in the Solution Explorer to right-click on, let alone get a context menu with the option View Class Diagram.

Note from the Author or Editor:
On page 52 please add this sentence to the 2nd to last paragraph (which currently ends with "then choosing View Class Diagram"):

"This feature is not available in the Express SKUs, only Standard and above."

Russ  Apr 29, 2011 
Printed
Page 59
Last Paragraph

The last sentence on page 59 mentions the following, "But as you will learn later in this book, because IQueryable inherits from ObjectQuery, it is possible to cast IQueryable to an ObjectQuery and then access those properties and methods".

The incorrect part of this statement is that "IQueryable inherits from ObjectQuery". It should say "ObjectQuery implements the IQueryable interface"

Below is the ObjectQuery class declaration.

class ObjectQuery<T> : ObjectQuery, IOrderedQueryable<T>, IQueryable<T>, IEnumerable<T>, IOrderedQueryable, IQueryable, IEnumerable, IListSource

Note from the Author or Editor:
Change sentence to:
But as you will learn later in this book, it is possible to cast IQueryable to an ObjectQuery and then access those properties and methods.

BarDev1  Feb 16, 2009  May 01, 2009
PDF
Page 62
In the C# Code

In this line of code:

var contacts = new ObjectQuery<Contact>(queryString, context);

ObjectQuery is not recognized unless you include a "using System.Data.Objects;" at the top of the file.

Minor detail, but it took me 20 minutes to find the right namespace to import. Just thought I would pass it along.

Note from the Author or Editor:
can you add a note somewhere on this page that says:

The namespaces in many of the examples are not spelled out along with the classes. Be sure to reference the appropriate namespaces at the top of your code files with Include for Visual Basic and using for C#. For example, for the ObjectQuery class you'll need Include System.Data.Objects (VB) or using System.Data.Objects; (C#).


(to editor: please use literal format for the words Include and using in the 2nd sentence and for the short statements in the last sentence (Include System.Data.Objects AND using System.Data.Objects; ))

Josh Williams  Feb 28, 2009  May 01, 2009
Printed
Page 62
2nd paragraph under the heading "The Parameterized ObjectQuery"

To use a parameterized query, you need to explicitly instantiate an ObjectQuery, rather than using the CreateQuery method of the ObjectContext.


I don't think the above is true. You can pass parameters even if you instantiate the object using CreateQuery:


string qstr =
"SELECT VALUE c FROM programmingEFDB1Entities.Contacts AS c WHERE c.FirstName = @firstName";
var contacts = context.CreateQuery<Contact>(qstr);
contacts.Parameters.Add(new ObjectParameter("firstName", "Robert"));

Note from the Author or Editor:
To use a parameterized query, you can add parameters to an ObjectQuery created with the CreateQuery method of the ObjectContext or to one which you have instantiated explicitly, as shown in the following example.

Kam_UK  Feb 28, 2009  May 01, 2009
Printed
Page 64
C# Example of Lambda Expression

The example in the book:
var contacts = context.Contacts
.Where(c => c.FirstName == 'Roberts');

The single quotations around Roberts is incorrect. Roberts should be surrounded by double quotation marks.

I do not have much experience with Lambda expressions, but the code would not compile when Roberts is surrounded by single quotation marks. When I surrounded Roberts with double quotation marks, the application compiled and seemed to work correctly.

BarDev1  Feb 16, 2009  May 01, 2009
Printed
Page 85
example 4-5

change

Dim Contacts = PEF.CreateQuery(Of DbDataRecord)(strQ)

to

Dim Contacts = context.CreateQuery(Of DbDataRecord)(strQ)

Note from the Author or Editor:
This is 1st edition. PEF.CreateQuery should be context.CreateQuery.

Ceulemans P  Dec 26, 2009 
Printed
Page 88
Example 4-9, C# version

Please replace "United Kingdom" with "UK".

Julia Lerman
Julia Lerman
 
Feb 17, 2009  May 01, 2009
Printed
Page 90
Example 4-12 C# code snippet

The Where clause is filtering on "United Kingdom" and should be "UK"

Note from the Author or Editor:
goes along with the same modification for example 4-9.

Fernando Soto  Feb 22, 2009  May 01, 2009
Printed
Page 96
Example 4-25

Missing parenthesis in the statement. Should be:

SELECT c.LastName,
ANYELEMENT(SELECT VALUE MAX(a.PostalCode)
FROM c.Addresses AS a)
FROM PEF.Contacts AS c

Note from the Author or Editor:
Please fix as noted

Bryan Owczarzak  Jul 01, 2009  Sep 01, 2009
Printed
Page 98
Example 4-28

Third line of code snippet:

ON variable.commonproperty EQUALS variableB.commonProperty

Should mostly be:

ON variableA.commonproperty EQUALS variableB.commonProperty

Fernando Soto  Feb 23, 2009  May 01, 2009
Printed
Page 101
Example 4-36

I tried to run example 4-36 and received the following error:

System.Data.EntitySqlException was unhandled
Message="'oa.FirstName' could not be resolved in the current scope or context. Make sure that all referenced variables are in scope, that required schemas are loaded, and that namespaces are referenced correctly., near multipart identifier, line 1, column 8."
Source="System.Data.Entity"
Column=8
ErrorContext="multipart identifier"
ErrorDescription="'oa.FirstName' could not be resolved in the current scope or context. Make sure that all referenced variables are in scope, that required schemas are loaded, and that namespaces are referenced correctly."

There was a lot more but I cut it out for the sake of brevity.

However, I changed to oa.FirstName, oa.LastName to be Add.FirstName and Add.LastName and all worked as it should.

Note from the Author or Editor:
p 101, example 4-36
change FIRST line of exmaple to
SELECT add.FirstName, add.LastName

CyclingFoodmanPA  May 27, 2009  Sep 01, 2009
Printed
Page 102
Next to last paragraph

syntax Group By MyTitle = Title

Should be

syntax Group By MyTitle = c.Title

Fernando Soto  Feb 23, 2009  May 01, 2009
Printed
Page 113
Example 4-53 C# 4th line

if (address.CountryRegion ==

Greg Lee  Jul 15, 2009 
Printed
Page 121
last dot on page 121

>Query projecting a single value that is an entity:
>
>SELECT VALUE c FROM PEF.Contacts AS c
>
>Each row of the DataReader that results is a DbDataRecord with one >column. The column contains an IExtendedDataRecord, which is a type >of a DbDataRecord. There is one column for every property in a >Contact entity, filled with the relevant data.

The query should goes without VALUE keyword:
SELECT c FROM PEF.Contacts AS c

Note from the Author or Editor:
Please make the change indicated above.

Krzysiek &#346;liwa  Jun 18, 2009 
Printed
Page 131
2nd to last paragraph

Please add

", which is in the System.Data namespace,"

into the first sentence of this paragraph so that it reads:

The EntityKey, which is in the System.Data namespace, is passed into the ..

Note that System.Data should be formatted similarly to the word EntityKey.

Thanks.

Julia Lerman
Julia Lerman
 
Feb 24, 2009  May 01, 2009
Printed
Page 144
Section "What about the stored procedure?"

The narrative explains that the CustomersbyState stored procedure returns rows from the Customer table and that the Customer table maps to the Customer entity.

At this point in the book we only have Address and Contact tables and entities.

The CustomersbyState stored procedure actually returns rows from the Contact table and in the next sections and Figures 6-5 and 6-6 we are shown how to map the CustomersbyState procedure to the Contact entity.

The references to Customer table and entity in the "What about the stored procedure?" section need to be changed to Contact table and entity.

Note from the Author or Editor:
Oy vey! Need to replace the word "Customer" with COntact in the following locations.

1) 4th paragraph (starts with "So far,...". "from the Customer table." should be "from the Contact table."

2) 5th paragraph, replace "from the Customer table" with "from the Contact table"

3) 5th paragraph, replace "to the Customer entity" with "to the Contact entity"

4) 5th paragraph, replace "equates to a Customer entity" with "equates to a Contact entity"

Thanks

Don DeCosta  Feb 28, 2009  May 01, 2009
PDF
Page 147
4th-5th paragraph

The page states that "You are no longer required to map all three functions and you
no longer need to provide foreign key parameters for entity references
when mapping."

In the next paragraph, the author warns about a misbehaviour concerning unmapped deletes calls when updates are mapped:
"There is a known behavior with respect to the mapping function feature.
If you map an update function but no delete function, you will get an
error when attempting to delete these entities"

According to official documentation (http://msdn.microsoft.com/en-us/library/cc716778.aspx)
"If you do not map all three of the insert, update, or delete operations of a entity type to stored procedures, the unmapped operations will fail if executed at runtime and an UpdateException is thrown."

This has proven to be true since I only mapped insert, and got EupdateException thrown on updates.

Note from the Author or Editor:
Please replace the sentence
"If you map an update function but no delete function, you will get an
error when attempting to delete these entities"

to:
"If you map some functions, but not all of them, and then attempt to execute one of the unmapped functions, you will get an UpdateException."

In NEXT sentence replace the word "both" with "all" ("does not require you to map all,)

Anonymous  Mar 28, 2011 
Printed
Page 153
paragraph labeled 5.

When run BreakAway creation script, then create EDM:

No sysdiagrams table exists. No sps related to diagrams are created. Using SQL 2008. This seems to be related to problem that by default objects required for system diagram in a database are not present. You must select on Database Diagrams to create New Database Diagram, and then even if you do not add tables, system objects required are added. Of course these do not exist when running BreakAway script to create database, thus no sysdiagrams, etc, which are referenced in this paragraph. The script has code trying to create sys.sp_addextendedproperty @name=N'MS_DiagramPane1', and I can find no reference to this in the database, nor do I understand what this is doing. Is it related to the sysdiagram?

I spent a little time with 'Teh Google', and although there are hints one can create a default Database Diagram setup with objects in the Model database, so this ability is by default added to any new database created, I have not yet found out where anyone was kind enough to explain just HOW to do it.

Anyway, this leaves us not certain as to whether anything we might need failed to be created by the script. Some clarification would be nice.

Note from the Author or Editor:
Please turn the paragraph into a TIP.

Modify the first sentence of that note to read:

If you have created a database diagram in the database, you would see a table named sysdiagrams in the list of tables.

Anonymous  Jun 22, 2009 
Printed
Page 156
10th row in Table 7-2

Lodging Destinations Destination
also should be
Lodging Locations Destination

Note from the Author or Editor:
thanks

Ryohsuke Fujioka  Oct 02, 2009 
Printed
Page 156
5th row in Table 7-2

Trip Destinations Destination
Should be:
Trip Locations Destination

Note from the Author or Editor:
under the column called "Original navigation property name" please change "Destinations" on the 5th row to "Locations"

Kam_UK  Mar 03, 2009  May 01, 2009
Printed
Page 165
In section BAGA assembly name second paragraph

The paragraph states:

Open the project's Properties window, and on the first page, Application, change the root namespace to BAGA.

Should read somthing like:

Open the project's Properties window, and on the first page, Application, change the root namespace, VB, default namespace, C#, to BAGA.

Note from the Author or Editor:
Open the project's Properties window, and on the first page, Application, change the root namespace (VB)/default namespace (C#) to BAGA.

Fernando Soto  Mar 02, 2009  May 01, 2009
Printed
Page 166
3rd paragraph

On Page 166, the paragraph starts with: "Figure 7-11 shows..." I believe it should say "Figure 7-12 shows..."

Note from the Author or Editor:
There is a problem with images 7-11 and 7-12. The one that is currently 7-11 (a screen shot of properties) should be the imaage displayed in figure 7-12 on p. 167. The one displayed in 7-12 should (Lutz Roeder's ....) should have been displayed in Figure 7-11. However, that one (Lutz Roeder's) should be completely replaced with a new screenshot. I th ought I sent this to you before the book went to print. The product is now "Red Gate's .NET Reflector". I will send the image to Loranah Dimant this morning (March 26th)

moflaherty  Mar 23, 2009  May 01, 2009
176, 177
various paragraphs

8.5. Mapping Stored Procedures
o UpdatePayment stored proc mapping
o Figure 8-5 does not display the 'Result Column Bindings' item for the RowVersion field

o DeletePayment stored proc mapping
o DeletePayment stored proc requires rowversion input parameter
o My solution was to remove the rowversion input parameter from the stored proc, save the stored proc, and 'Update Model from Database...' via the model's context menu

Note from the Author or Editor:
I am resending the updated image 8-5 directly to Scott Delugan at OReilly

Dan  Oct 20, 2010 
178, 179
8.6 Working with Many-to-Many Relationships section

o 8.6 Working with Many-to-Many Relationships
o The mapping identifies the EventActivities table as the target of the mapping, and then shows its ActivityID field wired up to the ActivityID field of the EventActivities table.
o the second 'EventActivities' table reference should reference the 'Activities' table.

Note from the Author or Editor:
p. 179, 2nd paragrph (starts with Instead), 2nd to last sentence ends with "field of the EventActivities table." Should be "field of the Activities table."

Dan  Oct 20, 2010 
Printed
Page 180
2nd paragraph from the bottom

Second paragraph from the bottom, 'Edit the grid's columns' the second line word 'Trim' should be 'Trip'.

RezaMohamed  Mar 28, 2009  May 01, 2009
Printed
Page 182
VB fragment

The second line of the VB is missing the "n" at the end of "resDateColumn":

.Columns(resDateColumn.Index) _

Mike Bridge  Jul 27, 2009 
Printed
Page 188
Paragraph titled "Test editing a customer"

Unless a person is experienced in winforms programming they are unlikely to know that it is necessary to tab out of a field (or otherwise blur it) in order to commit any changes. This must be done prior to saving or navigating to the next record (seems like a navigation to the next record should do this too, but it doesn't). You might put one of those little "trap" notes about this below the paragraph.

Note from the Author or Editor:
done in 2nd edition

Bill Hyde  Jun 26, 2009 
Printed
Page 188
First C# code sample on page

The VB and C# code don't match. The narrative explains that we'll be setting DataSources for activity and destination so the VB code matches the narrative but the C# code sets DataSources for customer and destination.

Note from the Author or Editor:
top of page, C# sample
first line begins with "customerBindingSource"

replace that line with :

activityBindingSource.DataSource = activities;

Don DeCosta  Feb 28, 2009  May 01, 2009
Printed
Page 188
First sentence on the page

Up to this point the book tells us to add two class level variables, Example 8-3 page 186, modify the form load event, Example 8-4 page 186, and add the method FillCombos, Example 8-5 page 187. On the top of page 188 we are told that we can run the application again to see how the ComboBoxes have been populated. But no instruction was made to make a call to FillCombos and so the ComboBoxes are not populated. I add the following to Example 8-4 on page 186 to the end of the code snippets.

VB FillCombos()

C# Fillcombos();

Note from the Author or Editor:
At the top of page 188, please modify the paragraph that currently reads:
"Run the application again if you want to see how the ComboBoxes have been populated so far."

Add BEFORE that sentence:

Insert a call to the FillCombos method (FillCombos for VB or FillCombos(); for C#) into the form's Load event You can put this line at the end of the existing code.

Please note that all three instances of the word FillCombos should be formatted as literal text. The third instance should also include the (); in the literal formatting.

Fernando Soto  Mar 09, 2009  May 01, 2009
Printed
Page 192
First c# code snippet

3 issues in this code snippet

1) "Now" is not valid on its own. For c# is should be "DateTime.Now".
2) Last line of code has "_adding". It should be "adding".
3) When creating the new BAGA.Contact you cannot use the default constructor (ie: new BAGA.Contact();). I am assuming you need to use the factory method (ie: BAGA.Contact.CreateContact(.....)). However if the new factory method is used it is unclear what values to pass into CreateContact for the arguments (ie: what would I put for ContactID?).

Note from the Author or Editor:
1) Change "Now" to "DateTime.Now" in the C# snippet.
2) p. 191 (VB sample) replace "_adding" with "adding"
3) p. 192 (end of VB sample) replace "_adding" with "adding"
4) p. 192 (end of C# sample) replace "_adding" with "adding"

Reader's comment #3 is incorrect. Resharper was suggesting that he replace the code with an object initializer which was confusing. The code in the book is correct.

James Steele  Mar 08, 2009  May 01, 2009
Printed
Page 195
line 1

On page 22 Using VWD 2010 Express Version there is no Console Application project choice. I probably made a mistake with this book as I really only use VB and did not want to download Visual C++ to do the examples. I found other ways of ploughing on - but came very unstuck on page 195. It only shows the C version - and the Download of Chapter 9 Winforms for VB from the web site has only the C code commented out - it does not seem to have the VB code anywhere.
Pete
PS I know that this excellent book is really only for serious Microsoft professionals, but perhaps you should make it clear that the book is very much geared to the professional versions of Visual Studio, and is alot easier to use if you really know C. It is hard going if you only know VB.

Note from the Author or Editor:
VWD is for web development. You should be using Visual Basic Express to do client side development - that would be console apps, winforms, wpf.

Pete Harrison  Jun 24, 2011 
Printed
Page 196
2nd paragraph after code listing

Text says:

Note from the Author or Editor:
ecch - editing issues.

1) Please remove the entire paragraph in question: "you can return the selection lists..."

2) top of p. 197, (vb code sample 8-11 continued from p. 196)
in first line of code, replace "Dim tripResults" with "trips"

thanks.







Pete Sutcliffe  Jun 04, 2009 
Printed
Page 207
Halfway

Example 8.18

In the VB portion, on the first set of code, should read, "New SortDescription" ....


Currently, it's showing as one word NewSortDescription

Paul Mc  Sep 24, 2009 
Printed
Page 207
Halfway

The C# and VB code do not match

c# lstBoxTrips.Items.SortDescriptions.Add(new SortDescription("StartDate", ListSortDirection.Ascending));

should read

lstBoxTrips.Items.SortDescriptions.Add(new SortDescription("StartDate", ListSortDirection.Descending));

Will Ferguson  Apr 07, 2009  May 01, 2009
Printed
Page 209
5th paragraph

Text says

Note from the Author or Editor:
Should read:

It's worth the effort to use this rather than the generic List so that you

Pete Sutcliffe  Jun 04, 2009 
Printed
Page 209
First set of code snippets

The C# code does not have a data type. Change

private ObservableTrips = new ObservableCollection<Trip>();

To

private ObservableCollection<Trip> ObservableTrips = new ObservableCollection<Trip>();

Fernando Soto  Mar 10, 2009  May 01, 2009
Printed
Page 211
Example 8-21

This code will only validate the first Trip in newTrips. The "Else Return True" in the For Each block will return if the first Trip is valid and Trip 2...n will never get tested.

Maybe something like this instead:

Function validateNewTrips() As Boolean
Dim newTrips = From t In ObservableTrips _
.Where(Function(t) t.TripId = 0)
For Each Trip In newTrips
If Trip.Lodging Is Nothing Then
Return False
ElseIf Trip.StartDate < Today Then
Return False
ElseIf Trip.EndDate < Trip.StartDate Then
Return False
End If
Next
' All must have been good
Return True
End Function

Note from the Author or Editor:
edits to VB example

remove the 11th & 12th line of the code sample that read
Else
Return True

Modify the 2nd to last line of the VB to read:
Return True 'when newTrips.Count=0 or all trips validate

In C# sample, same changes:
remove:
else
return true;

then modify 2nd to last line adding "or all trips validate" at the end

Don DeCosta  Feb 28, 2009  May 01, 2009
Printed
Page 211
Top of page.

In the C# code the \\ is being used as the start of a comment line. The correct characters should be // ....

Fernando Soto  Mar 10, 2009  May 01, 2009
Printed
Page 232
1st paragraph under The EntityState enums section

On page 232

Note from the Author or Editor:
Modify the sentence below "The EntityState enums" to

The EntityState property of an entity identifies whether the entity is:

BillHyde  Jul 20, 2009  Sep 01, 2009
Other Digital Version
257
4th Paragraph, code example

Author indicates the already instantiated object is myContact but then in the code example uses contact for the object name. The line should read:
context.AttachTo("Contacts", myContact);

Note from the Author or Editor:
yep. good catch. myContact

Anonymous  Jun 29, 2012 
Printed
Page 291
Setting up the DropDownList

One thing to be sure of is that the DropDownList has "Enable AutoPostBack" checked so that the upcoming binding to a dependent DetailsView will update as expected.

Note from the Author or Editor:
On page 291, there's a numbered list of steps. Please insert this item in between the current #3 and #4 and of course, increase the numbers for the items that follow it.

4. In the DropDownList's TaskList, check the "Enable AutoPostBack" CheckBox. This will ensure the correct behavior each time the user selects an item from the list.

Thanks!

Brian Hilltop  Mar 27, 2009  May 01, 2009
293, 294
Modifying the Template section

11.5. Overriding Default Code Generation
o 11.5.3.1. Inserting the Managed partial method in each entity class
o the Materialized partial method logic is not possible - the text suggests calling this partial method from the ObjectContext.ObjectMaterialized event handler; however, partial methods are implicitly marked as private. This means they cannot be called from outside the partial class.

Note from the Author or Editor:
On page 294, need to add to end of last pargraph prior to "Other wasy to create... " section.

Note that the partial method, Materialized, will be private and you cannot call it directly from the ObjectContext.ObjectMaterialized method. You'll need a wrapper method in the entity partial class, e.g., OnMateralized that is exposed and then calls the private method, Materialized.

Dan  Oct 20, 2010 
Printed
Page 299
United States

I was building the ASP.NET application from scratch when I found that after changing the combobox at the top of web page the corresponding payment listview did not remain in synch with currently selected Contact. I tried downloading your sample code and found the same problem. It seems that after I selected the combobox multiple times the payment details that showed up in ListView was for the previous selected Contact not the currently selected one. The inital web page that is displayed does have the correct information. Additionally, if the reservation listbox is selected by manually the payment details update correctly. I am concerned that somehow the postback events are being fired before the data is actually updated thus casuing the out of synch behavior I am observing. Please confirm that you can replicate the problem I am describing and let me know if you can come up with a solution. I am looking to use Entity Framework in a similar application and want to know if there is reason for concern with this data synchronization issue. I have tried many permutations to resolve this problem (i.e., clearing listview manually, changing listbox selection to -1 and then selecting to zero if reservation exist, etc.) and have not gotten this simple example to work correctly. A little heavy on the errata but great book nonetheless!

Thanks,
Joe

Note from the Author or Editor:
noted for 2nd edition

Joseph Isaacs  Sep 03, 2009 
Printed
Page 306
Last sentence of first paragraph of 'EntityDataSource and ViewState' section

I believe that the reference to 'ObjectDataSource' should instead be 'EntityDataSource'.

Note from the Author or Editor:
yes. thanks change to entitydatasource.

Chris Anderson  Nov 06, 2013 
Printed
Page 308
Top of page.

The first sentence states:

1. Create the first association by dragging an Association control from the ToolBox and attaching one end to Customer and the other to Activity.

If you attempt to drag the Association control onto the designer your cursor will change to and O with a line through it meaning that the operation can not be done. The sentence should read something like:

1. Create the first association by selecting the Association control from the ToolBox and then positioning the cursor on the Customer entity and left click on it and then moving the cursor on to the Activity entity and click on it.

Note from the Author or Editor:
change sentence to

Create the first association by selecting the Association control from the ToolBox and positioning the cursor on the Customer entity. Click on the Customer entity, which will set the first end of the association, then click the Activity entity to set the other end of the association.

Fernando Soto  Mar 19, 2009  May 01, 2009
Printed
Page 321
Example 12-3

The C# code has a couple of issues.

1. This line of code is incomplete. Needs the time stamp fields to be
added for both the Contacts and Customers tables

var newCust = Customer.CreateCustomer(0, "Nola", "Claire", DateTime.Now, DateTime.Now);

Modified code:
// Initialize two TimeSpamp's for the call to CreateCustomer
byte[] contactTimestamp = new byte[] {0,0,0,0,0,0,0,0};
byte[] customerTimestamp = new byte[] {0,0,0,0,0,0,0,0};

var newCust = Customer.CreateCustomer(0, "Nola", "Claire", DateTime.Now, DateTime.Now,
contactTimestamp, customerTimestamp);

2. The following error is thrown when SaveChanges is executed and the following statement is not added.

Entities in 'BAEntities.Contacts' participate in the 'FK_Customers_CustomerTypes'
relationship. 0 related 'CustomerTypes' were found. 1 'CustomerTypes' is expected.

Added the following line of code which adds a CustomerType "Silver" to the new Customer:
newCust.CustomerType = context.CustomerTypes
.Where(ct => ct.CustomerTypeName == "Silver").Select(ct => ct).First();

3. The following query:
// Query for a Customer and modify a new property
var firstCust = (from c in context.Contacts.OfType<Customer>()
select c).FirstOrDefault();

Returns a record whos BirthDate field is already set to 1/24/1981 so the following line should not cause the DB to be updated because you are modifying the field with the same value therefore no change.

firstCust.BirthDate = new DateTime(1981, 1, 24);

Note from the Author or Editor:
#1 is correct, please implement it
#2 is wrong - do not implement the proposed change. That setting is performed in SavingChanges
#3 change that line of code so that it is (1981,1, 26)

Fernando Soto  Apr 01, 2009  May 01, 2009
Printed,
Page 336
third paragraph above Creating POCO Classes

Then you?ll learn about another form of POCO support that let?s the POCOs behave similarly to EntityObjects at runtime.

let's is "let us"
lets is the third person singular verb agreement

Pretty sure anyway. :)

Note from the Author or Editor:
please change "let's" to "lets"

Anonymous  Aug 27, 2010 
Printed
Page 347
2nd paragraph

This is from the 2nd Edition. A step is missing from the instructions; the missing step is enclosed here in angle brackets:

"...comment out the call to DetectChanges that you added earlier," <replace the statement firstContact.Addresses.Add(newAddress) with firstContact.AddAddress(newAddress),> "and run the application again."

The example still works if you leave the call to Contact.Addresses.Add in place (because of the check for Contains), but does not work without the call to Contact.AddAddress

Note from the Author or Editor:
thanks

Geoff Dreyer  Oct 15, 2013 
PDF
Page 356
Top of page

Missing " before
new ArgumentException(\""

Note from the Author or Editor:
last 2 lines of p 356 & first 4 lines of 356 should look like this:
(note that becasue this form messes up formatting I am NUMBERING the lines for you but do not want these line n umbers in the book)

1) return System.Environment.NewLine +
2) " if (value != null && value.Length > " + aVal + ") " + System.Environment.NewLine +
3) " {throw new InvalidOperationException(\"" + prop.Name +
4) " must be less than " + aVal +" characters\");}" +
5) System.Environment.NewLine +
6) " else";

If this wrapping doesn't work in the constraints of the page format, email me and we'll work it out.

(Note to readers of this errata, not to be included in book...you can download the full template from the book's website learnentityframework.com)

Eric Smith  Nov 01, 2010 
Printed
Page 369
middle of page

three examples use the term BAModel.Customer in them for a total of four instances. All four should be changed to BAGA.Customer.

Note from the Author or Editor:
this is for 2nd edition. Now even I am making the mistake of not selecting the right edition when submitting errata! :)

Julia Lerman
Julia Lerman
 
Jun 05, 2011 
Printed
Page 379
2nd & 4th paragraph

Printed "The BreakAway database has a stored procedure called CreateCustomerfromClient".
Actual stored procedure's name is CreateCustomerfromContact.
In paragraph 4 was used the same erroneous reference.

Note from the Author or Editor:
Be sure to change both instances of this. Thanks!

Vitaly  Apr 04, 2009  May 01, 2009
Other Digital Version
411
The second sentence in the first step in the second set of instrucitons

In the instructions for creating the new 'NonCustomer' derived type, Step 1 notes "You can create a new entity by right-clicking the design window and selecting Add and then Entity, or by dragging an Entity from the Toolbox."

The subsequent steps assume you use the former method (the context menu). If you click-drag a new entity into the model, Visual Studio will automatically add an "Id" property to it. If you follow the rest of the steps and try to run the project, you will get mapping errors at runtime because the Id field is not mapped. In this case you must delete the "Id" property from the new entity.

Note from the Author or Editor:
thanks

Chuck Spencer  Jul 16, 2012 
Printed
Page 431
Top Of Page: First C# Code Section

When new reservations are added to an existing Customer, the code adds the new reservations to the variable "customerToUpdate". This variable represents the customer retrieved from the database for the purpose of initiating state tracking. But when updating existing reservations, the "customer" variable is utilized. This variable represents the recently edited customer.

Why not use the "customer" variable for both edits and inserts? If the EntityFrameWork understands updated Reservations for the "customer" variable, won't it also understand inserted Reservations for that same variable? (I understand that the Trip would still have to be adjusted for a Reservation insert.)

Thanks,
Mark

Note from the Author or Editor:
in this example, 2nd code line frmo the BOTTOM of the example, change
custtoUpdate.Resrvations.Add(res);

to
customer.Reservations.Add(res);

Mark Phillips  Jun 02, 2009 
Printed
Page 503
Table 16-1

The entries in difference column for lines 2, 4 and 5 are incorrect:
If 108 ms is 8% difference, then 320 ms, 412 ms and 207 ms difference are 320%, 412% and 207% difference respectivly.

Note from the Author or Editor:
please remove the difference from base column completely

Anonymous  Jun 17, 2009 
Printed
Page 647
Paragraph under example 22-3.

I have 2nd Edition. The paragraph references variables named eConn, eComm, and eReader. These do not exist in example 22-3. It appears the author is talking about connection, command, and dataReader.

Note from the Author or Editor:
whoops. right. Change text not example, accordingly

Del Lee  Oct 02, 2012 
Printed
Page 728
Example 22-8

In the VB sample, please move the line "End Using" so that it is just above the line "End Function". This will impact the tabbing. It should look like this:

Public Function GetTrips() As List(Of BAGA.DTO.Trip) _
Implements ICustomerService.GetTrips
Using listProvider As New BAGA.Providers.ListProvider
Dim tripsList = CType(ListProvider.GetReferenceList(Of Trip)(""), _
List(Of Trip))
Dim trips = From t In tripsList _
Select New BAGA.DTO.Trip With _
{.TripID = t.TripID, .TripDetails = t.TripDetails}
Return trips.ToList
End Using
End Function

In the C# sample, we need to move the first closing brace down so that it is just above the 2nd closing brace. Tabs affected here too.

public List<BAGA.DTO.Trip> GetTripsDTO()
{
using (var listProvider=new BAGA.Providers.ListProvider())
{
List<Trip> tripsList = (List<Trip>)listProvider.GetReferenceList<Trip>("");

var trips =
from t in tripsList
select new BAGA.DTO.Trip
{TripID = t.TripID, TripDetails = t.TripDetails};
return trips.ToList();
}
}

Note from the Author or Editor:
It looks like my attempt to show how to format the tabbing got wiped out by the submittal form. Please check with me when it's time to make this fix and I can show you what it should look like.

Julia Lerman
Julia Lerman
 
Feb 25, 2009  May 01, 2009
Printed
Page 736
2nd to last line of code on page

Please remove the line "add.TimeStamp=originalTS" that is just above "Next". This was accidentally left over when modifying the book's text to match refactored code.

Julia Lerman
Julia Lerman
 
Feb 25, 2009  May 01, 2009
Printed
Page 738
Example 22-15 bottom of page

More problems caused by updating the book's text after refactoring the code sample.

1)
Please change the line JUST ABOVE "Step 4" so that it says
"If custEF.EntityState_Local" instead of "If cust.EntityState_Local"

2)
Line just above "Step 2" should be:
"Using context = New BAEntities"
instead of "Using context = New BreakAwayEntities"

Julia Lerman
Julia Lerman
 
Feb 25, 2009  May 01, 2009
Printed
Page 739
top, code sample

place curly braces before and after the first line which is a comment.

SHould look like:

{
//we're not deleting customers
}

Note that there should be two paces in front of the middle line.

Julia Lerman
Julia Lerman
 
Feb 28, 2009  May 01, 2009
Printed
Page 746
middle of page - example 22-19

replacing RemoveChild method in C# sample

Here is the new C# version:

This form will mess up indentation, so please note:
2 spaces in front of third line. -->if (childEntity...
4 spaces in front of 4th line -->((Address)childEntity...
2 spaces in front of 5th line ---> if(childEntity...)
4 spaces in front of 6th line -->((Reservation)childEntity...

public void RemoveChild(object childEntity)
{
if (childEntity is Address)
((Address)childEntity).EntityState_Local = EntityStateLocal.Deleted;
if (childEntity is Reservation)
((Reservation)childEntity).EntityState_Local = EntityStateLocal.Deleted;
}

Julia Lerman
Julia Lerman
 
Feb 28, 2009  May 01, 2009
Printed
Page 748
bottom of page, 2nd line from the bottom

2nd line from the bottom should be
var add = cust.Addresses[i];


(replacing parens with square brackets)

Julia Lerman
Julia Lerman
 
Feb 28, 2009  May 01, 2009
Printed
Page 750-751
C# sample

Issues with last minute changes to text of C# code sample. (Readers can download the correct code sample from learnentityframework.com/downloads).

Starting with where the C# example begins in the middle of the page.

4th line should end with: GetCustomerList(); <--adding parens
5th line should end with: GetTripList(); <--adding parens
9th line: [randomPositioninList] <--replacing parens with square brackets
13th line: DateTime.Now.ToShortDateString(); <--adding "DateTime."

18: [cust.Reservation.Count-1]; <--replacing parens with square brackets
20 cust.RemoveChild(reslast); <--reslast replaces lengthy parameter

On page 749 where sample continues
5th line from top: Reservation[i]; <--replacing parens with square brackets

EDITOR: Please contact me (author) with any questions!

Note from the Author or Editor:
the note about p. 749 is accurate, I got my papers shuffled around. It's just part of a different sample.

Julia Lerman
Julia Lerman
 
Feb 28, 2009  May 01, 2009
Printed
Page 751
code sample at top of page

4th code line down, modifying code line and then adding another line of code below it.

var trip = triplist[randomPositioninList];
res.TripID = trip.TripID;


10th line down
var add = cust.Addresses[0]; <--replacing parens with square brackets


Julia Lerman
Julia Lerman
 
Feb 28, 2009  May 01, 2009