Wriju's BLOG

.NET, Cloud and everything

EF4 : Use MergeOption.NoTracking for better query performance

If you are just trying to fetch the data and has no intention to update it. Then you should be using the MergeOption.NoTracking to ensure that the ObjectStateManager does not store the required information for update and delete. Hence your query would be more quick in nature.

using (NorthwindEntities ctx = new NorthwindEntities())
    ctx.Customers.MergeOption = MergeOption.NoTracking;

So this simple line would add a lot of value to your performance and clearly visible in second call onwards.