0

We are using Entity Framework 4 and are creating our context using the repository pattern and using Structuremap for DI.

private readonly BLEntities _context;
public ProductService(BLEntities context)
{            
        _context = context;             
}

We have recently moved over to Azure and so at any one time we have two servers hosting the web site. Now if I get a product on one server, then go to the other server and update the product, then go back to the first server and reload the page I get the "old" results of the product. This is for testing so there is no caching being done on our side. Has this got to do with Entity Framework change tracking? If so, what should I do to alleviate this problem?

I am just running a simple select query to get the product.

var query = from p in _context.Products
            where p.ProductId == 1
            select p;

Thanks

Peuge
  • 1,461
  • 5
  • 20
  • 37
  • Do you try to persist the contexts somehow, or are they short lived? I don't know StructureMap but with Ninject I explicitly limit my context lifetime to request scope: kernel.Bind().To().InRequestScope(); – Neil Thompson Jan 29 '14 at 11:39
  • Hi Neil, I don't explicitly do any thing like that. For structure map I use For().Use(); so I guess the problem could be due to the context living for longer that it should? – Peuge Jan 29 '14 at 11:49
  • Are you sure that your reload isn't loading the web from the cache in the browser? Try the browser dev tools to check if the new web page request, are really going to the server. Have you tried to force a refresh in the web page with Ctrl + F5? – Paulo Correia Jan 29 '14 at 12:35

0 Answers0