1

Topic: ASP.NET MVC + EF6 - the data in UI is not updated

Greetings to all! A problem with ASP.NET MVC application - in UI shows the old data at their update directly in a SQL Server. Where to look? Can be in caching in EF6? In more details: ASP.NET MVC application + Repository Pattern c EF6 for data acquisition from a SQL Server. Under a Visual Studio all is normal (after update / adding of the data immediately in a SQL Server they appear in UI). After  versions on Web-server begin problems - if to update / to add the data directly in a SQL Server the updated data does not appear in UI. Help, please.

2

Re: ASP.NET MVC + EF6 - the data in UI is not updated

Hello, kirillmager, you wrote: K> Greetings to all! K> a problem with ASP.NET MVC application - in UI shows the old data at their update directly in a SQL Server. K> where to look? Can be in caching in EF6? A context in static variable you store? And generally show the code.

3

Re: ASP.NET MVC + EF6 - the data in UI is not updated

Hello, gandjustas, you wrote: G> Hello, kirillmager, you wrote: K>> Greetings to all! K>> a problem with ASP.NET MVC application - in UI shows the old data at their update directly in a SQL Server. K>> where to look? Can be in caching in EF6? G> the Context in static variable you store? G> and generally show the code. Digging in the code shows that business,  everything, in NavigationProperty. At update of their list in an update SQL Server in UI is not present. I try  them so: Parent GetParent (int parentId) {Parent parent = Holder. Get <Parent> ().FindSingle (new Specification <Parent> (p => p. ParentId == parentId)); Holder. ReloadNavigationProperty (parent, (p => p. Children)); return parent} the Code in class Holder for ReloadNavigationProperty: public void ReloadNavigationProperty <TEntity, TElement> (TEntity entity, Expression <Func <TEntity, ICollection <TElement>>> navigationProperty) where TEntity: class, IEntity where TElement: class, IEntity {((DbContext) Context).ReloadNavigationProperty <TEntity, TElement> (entity, navigationProperty);} the Code for an Extension-method public static class ReloadMethods {public static void ReloadNavigationProperty <TEntity, TElement> (this DbContext context, TEntity entity, Expression <Func <TEntity, ICollection <TElement>>> navigationProperty) where TEntity: class where TElement: class, IEntity {context. Entry (entity).Collection <TElement> (navigationProperty).Load ();} } Thus strangeness: at adding in a SQL Server of one more record for NavigationProperty update in UI is - is shown on 1 record more. And here if to delete in a SQL Server of record for NavigationProperty in UI any update (on F5) - remote record is shown.

4

Re: ASP.NET MVC + EF6 - the data in UI is not updated

Hello, kirillmager, you wrote: K> Hello, gandjustas, you wrote: K> Digging in the code shows that business,  everything, in NavigationProperty. Put, most likely, in that that Holder at you the static class and DbContext is used one on all requests. It is the unsupported scenario. The reason - is too much patterns. Singleton here at all to a place. Usage Specification too delivers. You really consider that code K> K> Parent parent = Holder. Get <Parent> ().FindSingle (new Specification <Parent> (p => p. ParentId == parentId)); K> it is better than var parent = ctx. Parent. Where (p => p. ParentId == parentId).FirstOrDefault ()? Especially it is enough to inscribe in the second variant Include and to receive at once the necessary records, instead of to drag their separate request.