Hi,
I'm new with EntityFramework.
My application has a pool of context object instances (Each context has 1 connection to the DB).
The problem is that when I update an object (and calling SaveChanges), the data is updated in the DB and in the updating context but when I select from other instance, it gets the old data of the selected object.
Example:
Let's imagine a table called tbl.
The table has 2 columns: id and data.
There is 1 row: id = 1, data = 2.
EFContext context1 = new EFContext();
EFContext context2 = new EFContext();
var obj1 = context1.tbl.Where(a => a.id == 1);
var obj2 = context2.tbl.Where(a => a.id == 1);
obj2.data = 10;
context2.SaveChanges();
var obj3 = context1.tbl.Where(a => a.id == 1);
After executing these lines, obj3.data contains 2, instead of 10.
How can I solve this problem?
I don't want to create a context instance every time I want to access the DB.
Refresh is not good enough I'll have to do it before every query (My application is multithreaded), and it takes a lot of time.
If I had a way to tell entity framework to perform a query every time I'm trying to select, it would be great.
Thanks!