Repository: dotnet/efcore
File: src/EFCore.Relational/Update/Internal/ColumnAccessorsFactory.cs (C#)

Code before:
    public static ColumnAccessors CreateGeneric<TColumn>(IColumn column)
        => new(
            CreateCurrentValueGetter<TColumn>(column),
            CreateOriginalValueGetter<TColumn>(column));

    private static Func<IReadOnlyModificationCommand, (TColumn?, bool)> CreateCurrentValueGetter<TColumn>(IColumn column)
        => c =>
        {
            if (c.Entries.Count > 0)
            {
                var value = default(TColumn);
                var valueFound = false;
                for (var i = 0; i < c.Entries.Count; i++)
                {
                    var entry = c.Entries[i];
                    var property = column.FindColumnMapping(entry.EntityType)?.Property;
                    if (property == null)
                    {
                        continue;
                    }

                    if (entry.EntityState == EntityState.Deleted
                        && entry.SharedIdentityEntry != null)
                    {
                        entry = entry.SharedIdentityEntry;
                    }

                    var providerValue = entry.GetCurrentProviderValue(property);
                    if (providerValue == null)
                    {
                        return (value!, valueFound);
                    }

                    value = (TColumn)providerValue!;
                    valueFound = true;
                    if (entry.EntityState == EntityState.Added
                        || entry.IsModified(property))
                    {
                        return (value, valueFound);
                    }
                }

                return (value, valueFound);
            }

            var modification = c.ColumnModifications.FirstOrDefault(m => m.ColumnName == column.Name);
            return modification == null
                ? (default, false)
                : modification.Value == null
                    ? (default, false)
                    : ((TColumn)modification.Value!, true);

Review comment (performance):
After redirecting to SharedIdentityEntry, the property should be re-looked up if the EntityTypes are different, following the pattern in CommandBatchPreparer.cs lines 1005-1014. The current code uses the property from the original entry's EntityType, which may not be valid for the SharedIdentityEntry if they have different types.

Suggested fix:
```csharp
if (entry.EntityState == EntityState.Deleted
    && entry.SharedIdentityEntry != null)
{
    var sharedEntry = entry.SharedIdentityEntry;
    var sharedProperty = sharedEntry.EntityType == entry.EntityType
        ? property
        : column.FindColumnMapping(sharedEntry.EntityType)?.Property;
    
    if (sharedProperty != null)
    {
        entry = sharedEntry;
        property = sharedProperty;
    }
}
```

Then use `property` in the subsequent GetCurrentProviderValue call.

Code after:
    public static ColumnAccessors CreateGeneric<TColumn>(IColumn column)
        => new(
            CreateCurrentValueGetter<TColumn>(column),
            CreateOriginalValueGetter<TColumn>(column));

    private static Func<IReadOnlyModificationCommand, (TColumn?, bool)> CreateCurrentValueGetter<TColumn>(IColumn column)
        => c =>
        {
            if (c.Entries.Count > 0)
            {
                var value = default(TColumn);
                var valueFound = false;
                for (var i = 0; i < c.Entries.Count; i++)
                {
                    var entry = c.Entries[i];
                    var property = column.FindColumnMapping(entry.EntityType)?.Property;
                    if (property == null)
                    {
                        continue;
                    }

                    var providerValue = entry.GetCurrentProviderValue(property);
                    if (providerValue == null)
                    {
                        return (value!, valueFound);
                    }

                    value = (TColumn)providerValue!;
                    valueFound = true;
                    if (entry.EntityState == EntityState.Added
                        || entry.IsModified(property))
                    {
                        return (value, valueFound);
                    }
                }

                return (value, valueFound);
            }

            var modification = c.ColumnModifications.FirstOrDefault(m => m.ColumnName == column.Name);
            return modification == null
                ? (default, false)
                : modification.Value == null
                    ? (default, false)
                    : ((TColumn)modification.Value!, true);
        };

    private static Func<IReadOnlyModificationCommand, (TColumn, bool)> CreateOriginalValueGetter<TColumn>(IColumn column)
        => c =>
        {
            if (c.Entries.Count > 0)