diff --git a/src/Neo/Persistence/DataCache.cs b/src/Neo/Persistence/DataCache.cs
index 016bed2ee2..88a290798e 100644
--- a/src/Neo/Persistence/DataCache.cs
+++ b/src/Neo/Persistence/DataCache.cs
@@ -316,7 +316,7 @@ public bool Contains(StorageKey key)
/// The key of the entry.
/// A delegate used to create the entry if it doesn't exist. If the entry already exists, the factory will not be used.
/// The cached data. Or if it doesn't exist and the is not provided.
- public StorageItem? GetAndChange(StorageKey key, Func? factory = null)
+ public StorageItem? GetAndChange(StorageKey key, [NotNullIfNotNull(nameof(factory))] Func? factory = null)
{
lock (_dictionary)
{