Handling concurrent stored procedure

May 26, 2015 at 4:21 PM
I'm using EFCache in an ASP.NET MVC application with Entity Framework. At the same time, a SQL Server Agent job directly calls a T-SQL stored procedure that updates the database (SQL Server 2008 R2). Is there a way to handle this such as clearing the EFCache per SqlDependency or how would you do this?
May 26, 2015 at 9:51 PM
The easiest way would be to remove all the items from the cache if the data in the database was changed. With the current API you could do that by invalidating all the entity sets - this is described in more details in this thread. An alternative would be to extend the caching mechanism by adding a method that removes all the items rather than doing this for individual entity sets. If you want to be more granular you could only remove results cached for tables that were touched by your stored procedure but it will probably a bit more complicated.