Refactor generated code to reflect the fact that SessionContext is per repository rather than global