How do I detach objects in Entity Framework Code First?

Shawn Mclean picture Shawn Mclean · Apr 8, 2011 · Viewed 100.3k times · Source

There is no Detach(object entity) on the DbContext.

Do I have the ability to detach objects on EF code first?

Answer

Slauma picture Slauma · Apr 8, 2011

This is an option:

dbContext.Entry(entity).State = EntityState.Detached;