diff --git a/Control/IOVSvc/CMakeLists.txt b/Control/IOVSvc/CMakeLists.txt
index 05ec344b8172a2efd00f01f4ddb88e7052f0c144..5e89b87f3c5e9e2af63f6e6411cf7aade3675093 100644
--- a/Control/IOVSvc/CMakeLists.txt
+++ b/Control/IOVSvc/CMakeLists.txt
@@ -25,7 +25,7 @@ atlas_add_library( IOVSvcLib
                    src/*.cxx
                    PUBLIC_HEADERS IOVSvc
                    INCLUDE_DIRS ${Boost_INCLUDE_DIRS}
-                   LINK_LIBRARIES ${Boost_LIBRARIES} AthenaBaseComps AthenaKernel SGTools GaudiKernel StoreGateLib SGtests
+                   LINK_LIBRARIES ${Boost_LIBRARIES} AthenaBaseComps AthenaKernel SGTools GaudiKernel StoreGateLib SGtests xAODEventInfo
                    PRIVATE_LINK_LIBRARIES TestTools EventInfo )
 
 atlas_add_component( IOVSvc
diff --git a/Control/IOVSvc/src/CondInputLoader.cxx b/Control/IOVSvc/src/CondInputLoader.cxx
index 81b9d9cf83d9f365e60ef9ee30768de4388bfa22..2f9f5e9284234dfce86fe842aac1587b40b727f2 100644
--- a/Control/IOVSvc/src/CondInputLoader.cxx
+++ b/Control/IOVSvc/src/CondInputLoader.cxx
@@ -199,7 +199,12 @@ CondInputLoader::execute()
   }
 
   EventIDBase now;
+#ifdef GAUDI_SYSEXECUTE_WITHCONTEXT
+  if (!getContext().valid()) {
+    ATH_MSG_WARNING("EventContext not valid! This should not happen!");
+#else
   if(getContext()==nullptr) {
+#endif
     const xAOD::EventInfo* thisEventInfo;
     if(evtStore()->retrieve(thisEventInfo)!=StatusCode::SUCCESS) {
       ATH_MSG_ERROR("Unable to get Event Info");
@@ -210,9 +215,15 @@ CondInputLoader::execute()
     now.set_time_stamp(thisEventInfo->timeStamp());
   }
   else {
+#ifdef GAUDI_SYSEXECUTE_WITHCONTEXT
+    now.set_run_number(getContext().eventID().run_number());
+    now.set_event_number(getContext().eventID().event_number());
+    now.set_time_stamp(getContext().eventID().time_stamp());
+#else
     now.set_run_number(getContext()->eventID().run_number());
     now.set_event_number(getContext()->eventID().event_number());
     now.set_time_stamp(getContext()->eventID().time_stamp());
+#endif
   }
   IOVTime t(now.run_number(), now.event_number(), now.time_stamp());