diff --git a/src/caosdb/apiutils.py b/src/caosdb/apiutils.py
index a46e30375b924d358448e73aece61562c36c700b..fec520b5ccf79d45a7ce46439f4550453dc3bdbb 100644
--- a/src/caosdb/apiutils.py
+++ b/src/caosdb/apiutils.py
@@ -178,6 +178,16 @@ def getCommitIn(folder):
     return get_commit_in(folder)
 
 
+def entity_and_id(this, that):
+    """
+    returns true iff exactly one of this and that is an Entity with an ID and the other is an
+    integer
+    """
+    return (
+        (isinstance(this, Entity) and this.id is not None and isinstance(that, int))
+        or (isinstance(this, int) and isinstance(that, Entity) and this.id is not None))
+
+
 def compare_entities(old_entity: Entity, new_entity: Entity, compare_referenced_records: bool = False):
     """Compare two entites.
 
@@ -279,6 +289,15 @@ def compare_entities(old_entity: Entity, new_entity: Entity, compare_referenced_
             if (prop.value != matching[0].value):
                 # basic comparison of value objects says they are different
                 same_value = False
+
+                # one Entity with ID and one int?
+                if (sufficient_id and ):
+                    if ((isinstance(matching[0].value, int)
+                         and prop.value.id == matching[0].value)
+                            or (isinstance(prop.value, int)
+                                and prop.value == matching[0].value.id)):
+                        same_value = True
+
                 if compare_referenced_records:
                     # scalar reference
                     if isinstance(prop.value, Entity) and isinstance(matching[0].value, Entity):