In the process of updating my book, I have to recheck every statement and every line of code. A lot has changed. It’s as though I were writing the whole thing from scratch.
Here’s a small but notable change that I found.
In .NET 3.5 you cannot Load an EntityReference for an Added entity even when the entity has the critical piece of information — the EntityReference.EntityKey of the item to be loaded. It will fail with an exception.
In .NET 4, it works. You can set the foreign key property or the EntityReference.EntityKey and then load that related entity either explicitly or via lazy loading.
I’m pretty sure this is a result of the improvements made to the query generation. .NET 3.5 had a convoluted way of loading entity reference data. Now it’s more straightforward. However, I have only tested it with FKs.
Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!