Search code examples
c#.netwcfentity-frameworkodata

Model Tracking In Entity Framework


We were using Microsoft WCF Web Services and Entity Framework ORM in our project.

When client call each Web Services,Entity Framework keep state of each model in memory for tracking model state for each client. In this case memory usage will going up extremely in server.We don't need to tracking model in client side so we set MergeOption to NoTraking in client,But it seems not working.

Is there any option for this problem?


Solution

  • You can use the .AsNoTracking() method - this means that Entity Framework won't try to keep track of any changes to the entities. Example:

    var items = context.Foo.AsNoTracking();
    

    Recommended reading:

    Entity Framework and AsNoTracking