added exception handling for dbcontext access