I am developing student marking system using ASP.NET MVC and Entity Framework. There is a heavy method I am using for calculate marking. At a given time there are about 50 users enter marks to system and that heavy method call by all the users. It gives me deadlock most of the time. I am using a TransactionScope
.
This is my code:
try
{
using (context = new SIMSDBAPPEntities())
{
using (TransactionScope scope = new TransactionScope())
{
// My heavy calculation
}
scope.Complete();
context.SaveChanges();
}
catch (Exception ex)
{
throw ex;
}
}
My heavy method is running inside a TransactionScope
. I want to know whether my code has any problems? If yes, what can I do to avoid deadlock situation?