Programming Entity Framework: Code First

Errata for Programming Entity Framework: Code First

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
Page Example 2-3
Right after Example 2-7

And there it is, DataAccess.BreakAwayContext with a Destinations table and a Lodgings table. That EdmMetadata table is used by Code Firstís database initialization, and youíll learn more about that later. "I do not have a "EdmMetaData" table when I run this project. (Example 2-3) I only have "dbo.Destinations" and "dbo.Lodgings" tables in my SQLEXPRESS database. How do I get that table?? If I will not need it later in the book I will not worry about it, but just very CURIOUS as to why I do not have that table. My project ran without any errors etc.. Many Thanks, Super Dave

Note from the Author or Editor:
This changed with EF 4.3 when they introduced migrations. This blog post that I wrote has more details about this change:

Super Dave  Oct 15, 2012 
Page 7,8
beginning with last paragraph on page 7

The process as described in the book up to page 7 work perfectly. If you run the Console project repeatedly the rows will keep being added to the database table. So far so good. However, in VS 2010 SP1, when I create a connection in Server Explorer to the SQLExpress file, the following problems occur: (the only work-around I found for this is to rename the context file but it has to be a name that was not previously used.) Obviously, I can't continue with this book unless I can also view the contents of the database. When the connection is open I get this error: at System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action)</StackTrace><ExceptionString>System.Data.EntityException: The underlying provider failed on Open. ---&gt; System.Data.SqlClient.SqlException: Unable to open the physical file "C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\DataAccess.MyBreakAwayContext.mdf". Operating system error 32: "32(The process cannot access the file because it is being used by another process.)". Unable to open the physical file "C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\DataAccess.MyBreakAwayContext_log.LDF". Operating system error 32: "32(The process cannot access the file because it is being used by another process.)". When the connection is close or deleted for VS 2010 Server Explorer, I get this error when I try to run the console project: {"An exception occurred while initializing the database. See the InnerException for details."} {"The underlying provider failed on Open."}

Note from the Author or Editor:
on page 29 there is a warning note at the top of the page. It currently has two paragraphs. Please add a 3rd paragraph that states : If you are using the Server Explorer in Visual Studio to look at the database, then you'll need to close the Server Explorer's connection to the database in order for Code First to drop and recreate the database. You can do this by right-clicking the database connection in Server Explorer and choosing "Close Connection".

Anonymous  Nov 25, 2011 
Page 8
Figure 1-3

There is a mismatch between the schema for table Patient and the class definition of Patient on page 5. The table is missing a column for FirstVisit. Since FirstVisit isn't used elsewhere in the Chapter, it should probably be dropped from the class rather than added to the database.

Note from the Author or Editor:
please removethe line: public DateTime FirstVisit { get; set; } in example 1-1

Anonymous  Dec 20, 2011 
Page 14

figure 1-5..."Yes" between "existing classes" and "prefer visual designer" is supposed to be "No".

Julia Lerman
Julia Lerman
O'Reilly Author 
Nov 30, 2011 
Page 40
End of Section "Mapping keys"

It says "At the end of this section, youíll see how to configure composite keys." but I can't find any more information about composite keys.

Note from the Author or Editor:
For reader. yeah ..we totally blew that. Sorry. Check this EF team blog post and you'll see a composite key via data annotations if you look at the LadyInWaiting class. Here's the MSDN topic that has in it how to fluently configure composite keys. For O"Reilly - if we get more mentions of this, we'll consider adding in a little text. For now, just leave it be.

bennedik  Jan 06, 2012 
Other Digital Version
At example 3-9 There is a change between the text talking about the example and the actual example. The text says "UpdatePerson" but the example header and the example itself are "UpdateTrip"

Note from the Author or Editor:
reader is correct. Just above Example 3-9. Could swear we caught this during the last round of QC before printing. :) Ah well.

MikeScott8  Dec 31, 2011 
Printed, PDF
Page 94
Example 5-2, the first line of the first statement in the constructor

The statement should read: Property(d => d.Name) .IsRequired().HasColumnName("LocationName");

Note from the Author or Editor:
correct ....add "e)" to that first line

Anonymous  Dec 22, 2011 
Printed, PDF
Page 96
End of the 5th paragraph

This section is referring to the PersonPhoto entity. It states: "The Person and PersonTable classes meet these requirements". Should state: "The Person and PersonPhoto classes meet these requirements".

Note from the Author or Editor:
yes please fix as per the submission

Anonymous  Mar 09, 2012 
Page 101
Example 5-10

Need to make three MINOR changes to the visual basic code listing 1&2) moving period from start of a line to the end of the previous line in two cases: So here I've add the period to the end of the first line, removed it from start of 2nd, added to end of third and removed from start of 4th. Me.Property(Function(d) d.Name). IsRequired().HasColumnName("LocationName") Me.Property(Function(d) d.DestinationId). HasColumnName("LocationID") 3) there is a section of t his code that starts with Me.Map followed by a section that starts with Map. That seconde one also needs to be Me.Map. Thanks!

Julia Lerman
Julia Lerman
O'Reilly Author 
Feb 23, 2012 
Page 141
First code fragment

Database.SetInitializer(null); This code results in a compile time error. I think the correct code should be Database.SetInitializer<MyContextType>(null);

Note from the Author or Editor:
correct...our mistake (typo) please change to Database.SetInitializer<BreakawayContext>(null);

bennedik  Jan 06, 2012