Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is MergeOption in Entity Framework 6?

I'm used to Entity Framework 4, where, when calling certain views I had to be sure to set MergeOption to NoTracking like so

SHEntity.qry_UserPermissions.MergeOption = System.Data.Objects.MergeOption.NoTracking;

But in updating to EF 6.1 I don't even see MergeOption as part of qry_UserPermissions anymore. I have to set this or EF will sometimes combine records when I don't want it to. I've googled around and haven't had any luck, even though it seems like a simple issue to me.

How do I turn off tracking in EF 6.1?

like image 867
cost Avatar asked May 25 '14 06:05

cost


1 Answers

using AsNotrack() method entity, you may stop tracking of entity in EF this can be written we you querying on context.

Example.

using (SHEntity context = new SHEntity())
{
   var up = context.qry_UserPermissions.AsNoTracking().ToList();
}
like image 167
Jignesh Trivedi Avatar answered Oct 16 '22 18:10

Jignesh Trivedi