Entity Framework 4.1+ many-to-many relationships change tracking

Here is how to find all the changed many-to-many relationships. I’ve implemented the code as extension methods: public static class IaExtensions { public static IEnumerable<Tuple<object, object>> GetAddedRelationships( this DbContext context) { return GetRelationships(context, EntityState.Added, (e, i) => e.CurrentValues[i]); } public static IEnumerable<Tuple<object, object>> GetDeletedRelationships( this DbContext context) { return GetRelationships(context, EntityState.Deleted, (e, i) => e.OriginalValues[i]); … Read more

Global setting for AsNoTracking()?

Since this question is not tagged with a specific EF version, I wanted to mention that in EF Core the behavior can be configured at the context level. You can also change the default tracking behavior at the context instance level: using (var context = new BloggingContext()) { context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; var blogs = context.Blogs.ToList(); … Read more