Disabling Change Tracking in Entity Framework

This might come handy in case, you are having performance issue with Entity Framework and Change Tracking Option.

Short version :

using (SchoolEntities context = new SchoolEntities())
{
 context.Course.MergeOption = MergeOption.NoTracking;

 foreach (var course in context.Course)
 {
 // the courses we enumerate are detached state
 Console.WriteLine("{0} {1}", course.CourseID, course.Title);
 }
}
using (SchoolEntities context = new SchoolEntities())
{ 
 var query = new ObjectQuery<Course>(
 "SELECT VALUE c FROM SchoolEntities.Course AS c", 
 context, 
 MergeOption.NoTracking);

 foreach (var course in query)
 {
 // the courses we enumerate are detached state
 Console.WriteLine("{0} {1}", course.CourseID, course.Title);
 }
}

Thanks to Gil Fink’s for this post.

Read the whole article from : http://blogs.microsoft.co.il/blogs/gilf/archive/2009/02/20/disabling-change-tracking-in-entity-framework.aspx