O'Reilly logo

Fluent Entity Framework by Rebecca M. Riordan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Updating & deleting entities

There really isn’t very much for me to say about updating and editing entities. Changing a property is changing a property. As for deleting? Well, you need to call a different method depending on which API you’re using (ObjectContext.DeleteObject() or DbSet<T>.Remove()), and I’ve already told you that the entities aren’t actually deleted until after the database is updated by a call to SaveChanges().

But there is one thig we haven’t discussed: What happens to an entity when an entity it is related to is removed from the database? Let’s look at how that works:

It all depends on the nullability of the foreign key. That determines whether the relationship is optional or required. If the foreign key can be null, the relationship ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required