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.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

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

Version Location Description Submitted by Date submitted
ePub Page Example 6-3

Not sure if I already submitted this.
Maybe this isn't an error. I couldn't get this code to insert a record:
var contact = context.Contacts.Where(c => c.FirstName == "Robert").First();
var address = new Address();
address.Street1 = "One Main Street";
address.City = "Burlington";
address.StateProvince = "VT";
address.AddressType = "Business";
address.ModifiedDate = DateTime.Now;
//join the new address to the contact
address.Contact = contact;
context.SaveChanges();

Immediately before the last line I added:
context.Addresses.AddObject(address);

I couldn't see how the new address could be saved without something like this as the context wouldn't know about the new address.

Mike McCarthy  Feb 17, 2014 
Printed Page 99
2nd paragraph

This relates to the sample code at the top of page 98. The discussion of the code?s behavior explains why lazy loading was disabled for this example (so we could see that a record with two addresses is listed once with only one address and again with both addresses).

What?s missing is an explanation of the behavior of the code with lazy loading enabled; in this case we still get two occurrences of the record and both occurrences contain both addresses. I?d like to know why this happens.

Anonymous  Aug 26, 2011 
PDF Page 114
Example 5-3

The foreach loop for addresses in the example 5-3 uses the .Addresses collection for the current contact (contact.Addresses). I would have thought that c[1] would somehow be involved as we are trying to see projections in Entity SQL. I can remove c.Addresses from the query text at the top and it still works, showing that the second property is not being used by the example code. Or am I missing something?

MartinC  Dec 26, 2011 
Printed Page 181
Figure 8-8

Figure 8-8 contains 13 entities whereas my BAModel contains 16. The entities in my model which do not appear in the figure are OldReservation, CustomersinPastYear and vPaymentsforPeriod.

I created my database using ?BreakAway Database.exe?. Was this the wrong database or is there some other reason my model does not match the one in the figure?

Also, some of the field names differ between my model and Figure 8-8. For example, the Trip entity shows a Navigation Property ?Destination?. My model has this property as ?Location?. Was I supposed to have changed this while cleaning up the model?

There are other differences as well. Figure 8-8 shows an Activity Navigation Property ?Equipment?; in my model this property is called ?Equipments? (I set the Entity Set Name to EquipmentSet). My model?s Reservation entity has a Navigation Property ?Event? which is listed as ?Trip? in Figure 8-8. Etc.

Anonymous  Sep 06, 2011 
Printed Page 275
Last paragraph

The sentence "In C#, you need to wire up the event handler in the OnContextCreated method..." is confusing. The programmer needs to create a OnContextCreated as done in the Entities.cs. The phrasing "wire up ... in" implies there is something to be done in an existing method.

Jim Roberts  Aug 23, 2011 
Printed Page 290
1st example

Example 11-21 shows the signature of the CreateContact method incorrectly (the last parameter is missing):


public static Contact CreateContact (int contactID, string firstName, string lastName, global::System.DateTime addDate, global::System.DateTime modifiedDate)


The signature is actually:

public static Contact CreateContact(global::System.Int32 contactID, global::System.String firstName, global::System.String lastName, global::System.DateTime addDate, global::System.DateTime modifiedDate, global::System.Byte[] rowVersion)

The PDF file contains the same error on page 292.

Leroy Casterline  Sep 28, 2011 
Printed Page 294
Example 11-23

Example 11-23 is erroneously titled ?Overriding the Create factory method.? This is the title from example 11-22 which really does override that method.

The same error appears in the PDF version.

casterle  Sep 29, 2011 
Printed Page 294
Example 11-24

Example 11-24 is erroneously titled ?Overriding the Create factory method.? This is the title from example 11-22 which really does override that method.

casterle  Sep 29, 2011 
Printed Page 337
Example 13-1

The Contact class provided in the database has the RowVersion field. The example code int the book needed the property

public byte[] RowVersion {get; set;}

to work correctly for me.

The same problem occurred in the Address class on page 338.

JIm Roberts  Aug 27, 2011 
Printed Page 369
Bottom half of the page

The Entity SQL examples on the page refer to BAModel.Customer, which generates an exception ?Type 'BAModel.Customer' could not be found?.

The references should be to BAGA.Customers.

The same errors appear in the PDF file on pages 371 and 372.

Leroy Casterline  Oct 07, 2011 
Printed, PDF Page 422
Stored Procedure

The stored procedure printed on the page as well as the stored procedure in the downloadable sample database are wrong and prevent Example 16-2 from executing. The errors printed on page 422 differ from the errors in the database. The error in the PDF file is on page 424.

The correct stored procedure (or at least a procedure which does not throw an exception) is:

USE [BreakAway - Working]
GO
/****** Object: StoredProcedure [dbo].[CustomersWhoTravelledinDateRange] Script Date: 10/13/2011 22:39:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[CustomersWhoTravelledinDateRange]

--returns customer records with contact info for customers
@startdate DATETIME,
@enddate datetime

AS

SELECT Customers.ContactID,
Customers.PrimaryDesintation as PrimaryDestinationID,
Customers.CustomerTypeID,
Customers.InitialDate,
Customers.SecondaryDestination as SecondaryDestinationID,
Customers.PrimaryActivity as PrimaryActivityID,
Customers.SecondaryActivity as SecondaryActivityID,
Customers.Notes,
Customers.RowVersion,
Contact.FirstName,
Contact.LastName,
Contact.Title,
Contact.AddDate,
Contact.ModifiedDate,
ContactPersonalInfo.BirthDate,
ContactPersonalInfo.HeightInches,
ContactPersonalInfo.WeightPounds,
ContactPersonalInfo.DietaryRestrictions,
Contact.RowVersion as CustomerRowVersion
FROM Customers INNER JOIN
Contact ON Customers.ContactID = Contact.ContactID INNER JOIN
ContactPersonalInfo ON Customers.ContactID = ContactPersonalInfo.ContactID
WHERE customers.contactid IN
(SELECT Customers.COntactID
FROM Customers INNER JOIN
Reservations ON Customers.ContactID = Reservations.ContactID INNER JOIN
Events ON Reservations.EventID = Events.EventID
WHERE events.startdate>=@startdate AND events.startdate<=@enddate
GROUP BY CUstomers.contactid)

Leroy Casterline  Oct 13, 2011 
Printed, PDF Page 425
Example 16-3

In example 16-3, MyClass includes an int? Age. This variable should be defined as Decimal? to avoid an exception when the query is run.

This error is on page 426 in the PDF file.

Leory Casterline  Oct 14, 2011 
792
example 27-3

For the sake of continuity and to avoid confusion, the same string should be used as the index value to ViewState[ ] in both lines of the example, i.e., use either "myKey" or "custKey" in both lines of the example.

Anonymous  Sep 29, 2011