Added code to automatically apply pending migrations when not in Debug mode.