Jak wiem Entity Framework implementuje Pattern mapy tożsamości, więc EF buforuje niektóre jednostki w pamięci.Jak unieważnić strukturę encji 4 Wewnętrzna pamięć podręczna
Pozwól, że dam ci przykład.
var context = new StudentContext();
var student = context.Students.Where(st => st.Id == 34).FirstOrDefault();
// any way of changing student in DB
var anotherContext = new StudentContext();
var anotherStudent = anotherContext.Students.Where(st => st.Id == 34).FirstOrDefault();
anotherStudent.Name = "John Smith";
anotherContext.SaveChanges();
student = context.Students.Where(st => st.Id == 34).FirstOrDefault();
// student.Name contains old value
Czy istnieje sposób, aby unieważnić cache Pierwszy kontekst i pobrać nowe student
podmiot bez odtworzenie kontekstu?
Dzięki za pomoc.