Tip 9 – How to delete an object without retrieving it

Problem The most common way to delete an Entity in the Entity Framework is to pull the Entity you want to delete into the context and then delete it like this: // Find a category by ID by // TRIVIA: in .NET 4.0 you can use .Single() // which will throw if there is more…

16

Side effects of first class Associations

You’ve probably all heard someone say that Entity Data Model (EDM) and more specifically the Entity Framework (EF) treat associations as first class concepts. This sentence, seems reasonably benign, but it has a profound effect on the Entity Framework’s behavior. Allow me to illustrate by way of an example: Imagine you want to model a…

9