EF returns old values

前端 未结 3 1973
甜味超标
甜味超标 2020-12-18 02:25

I\'m using EF6 + WPF with MVVM design pattern in my desktop application. I\'m using also Autofac as DI container.

I read a lot about EF context lifetime management

3条回答
  •  萌比男神i
    2020-12-18 03:06

    Following method forces EF to requery the query to the database and do not cache the result:

    this.context.someTable.AsNoTracking().Where(arg => arg.value == "value").Single();
    

    The important method call is AsNoTracking

提交回复
热议问题