This package has what I would call a mistake. A prerequisite for not having a process session is that multiple instances can control how the session state is cleared. In this case, all instances run this method ...
private void PurgeExpiredSessions() { using (SessionEntities entities = ModelHelper.CreateSessionEntities(this.ConnectionString)) { foreach (SessionEntity entity in QueryHelper.GetExpiredSessions(entities)) { entities.DeleteObject(entity); } entities.SaveChanges(); this.LastSessionPurgeTicks = DateTime.UtcNow.Ticks; } }
The problem is that one instance deletes entities in front of the other (s), and entities generates the error described in the message. I asked the authors of the package to free the source code or fix it. My patched text editor fix would be to add a public virtual one, so you can override the method or just change it too.
private void PurgeExpiredSessions() { using (SessionEntities entities = ModelHelper.CreateSessionEntities(this.ConnectionString)) { var sqlCommand = @"DELETE dbo.Sessions WHERE Expires < GETUTCDATE()"; entities.ExecuteStoreCommand(sqlCommand); this.LastSessionPurgeTicks = DateTime.UtcNow.Ticks; } }
The authors of the packages are very quick to answer (answered when publishing this!), And today they stated that they are working on the release of the code, but can simply fix it. I asked ETA and will try to keep an eye on him if I get it.
Great package, it just needs a little maintenance.
The correct answer is: wait until the source code is released or the patch is updated. Or decompile and fix it yourself (if it is consistent with the license!)
* Updating package owners is considering fixing it this week. Yes! ** Update.SOLVED !!! They obviously fixed it a while ago, and I installed the wrong package. I used http://nuget.org/packages/System.Web.Providers , and I had to use http://nuget.org/packages/Microsoft.AspNet.Providers/ .. It was not obvious to me which one was heir and included in another package. They wrapped him in an empty catch.
private void PurgeExpiredSessions() { try { using (SessionEntities entities = ModelHelper.CreateSessionEntities(this.ConnectionString)) { foreach (SessionEntity entity in QueryHelper.GetExpiredSessions(entities)) { entities.DeleteObject(entity); } entities.SaveChanges(); this.LastSessionPurgeTicks = DateTime.UtcNow.Ticks; } } catch { } }
Thanks to the package team for such quick answers and great support!