EF 4.1 Quick Tip: Add/Attach Returns Your Entity

We did a few things in EF 4.1 that were not at all ground-breaking or cool or anything like that, but were intended only to make programming a little bit more pleasant. One of those was making the Add and Attach methods return a reference to the added or attached entity.

Continue reading


Code First: Inside DbContext Initialization

A lot of stuff happens when you use a DbContext instance for the first time. Most of the time you don’t worry about this stuff, but sometimes it’s useful to know what’s happening under the hood. And even if it’s not useful, it’s hopefully interesting for its geek value alone.

Continue reading

Why Your Feedback Is So Important

(Or: How I Learned to Stop Worrying and Love CTPs)

Back in about 2001 I read Kent Beck’s Extreme Programming Explained for the first time. It changed my life as a programmer. Of course, Agile is now well-accepted and I’m always a little surprised when I encounter software journeymen* not at least trying to be Agile. But working on framework code that is used by thousands of apps can make some aspects of being Agile quite difficult.

Continue reading

A Brief History of EF 4.1

There’s a fairly common misconception that EF4 was the fourth version of the Entity Framework. It’s a reasonable assumption to make, but actually EF4 was only the second released version of EF. It was called EF4 not because it was version 4, but because it was released as part of .NET 4.0.

You may also have heard the EF4.1 builds on top of EF4 without changing the “core” libraries. What does this mean? Read on to find out more and dazzle your friends with EF trivia.

Continue reading

Rejecting changes to entities in EF 4.1

Imagine your app has an entity to which changes have been made and you want to reject those changes such that they won’t be saved to the database when SaveChanges is called. Using Entity Framework 4.1 you can do this by setting the state of the entity to Unchanged. For example:

context.Entry(myEntity).State = EntityState.Unchanged;


Continue reading