Repository: dotnet/efcore
File: src/EFCore/ChangeTracking/Internal/InternalEntityEntry.cs (C#)

Code before:

        base.OnPropertyChanged(propertyBase, value, setModified);
    }

    /// <summary>
    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
    ///     any release. You should only use it directly in your code with extreme caution and knowing that
    ///     doing so can result in application failures when updating to a new Entity Framework Core release.
    /// </summary>
    public override void HandleConceptualNulls(bool sensitiveLoggingEnabled, bool force, bool isCascadeDelete)
    {
        var fks = new List<IForeignKey>();
        foreach (var foreignKey in EntityType.GetForeignKeys())
        {
            // ReSharper disable once LoopCanBeConvertedToQuery
            var properties = foreignKey.Properties;
            foreach (var property in properties)
            {
                if (PropertyStateData.IsPropertyFlagged(property.GetIndex(), PropertyFlag.Null))
                {
                    var isSetDefault = foreignKey.DeleteBehavior is DeleteBehavior.SetDefault or DeleteBehavior.ClientSetDefault;

                    if ((properties.Any(p => p.IsNullable) || isSetDefault)
                        && foreignKey.DeleteBehavior != DeleteBehavior.Cascade
                        && foreignKey.DeleteBehavior != DeleteBehavior.ClientCascade)
                    {
                        foreach (var toNull in properties)
                        {
                            if (isSetDefault)
                            {
                                this[toNull] = toNull.Sentinel;
                            }
                            else if (toNull.IsNullable)
                            {
                                this[toNull] = null;
                            }
                            else
                            {
                                PropertyStateData.FlagProperty(toNull.GetIndex(), PropertyFlag.Null, isFlagged: false);
                            }
                        }
                    }
                    else if (EntityState != EntityState.Modified
                             || IsModified(property))
                    {
                        fks.Add(foreignKey);
                    }

                    break;
                }

Review comment (suggestion):
```suggestion
                    if (isSetDefault
                        || ((properties.Any(p => p.IsNullable)
                            && foreignKey.DeleteBehavior != DeleteBehavior.Cascade
                            && foreignKey.DeleteBehavior != DeleteBehavior.ClientCascade))
```

Code after:

        base.OnPropertyChanged(propertyBase, value, setModified);
    }

    /// <summary>
    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
    ///     any release. You should only use it directly in your code with extreme caution and knowing that
    ///     doing so can result in application failures when updating to a new Entity Framework Core release.
    /// </summary>
    public override void HandleConceptualNulls(bool sensitiveLoggingEnabled, bool force, bool isCascadeDelete)
    {
        var fks = new List<IForeignKey>();
        foreach (var foreignKey in EntityType.GetForeignKeys())
        {
            // ReSharper disable once LoopCanBeConvertedToQuery
            var properties = foreignKey.Properties;
            foreach (var property in properties)
            {
                if (PropertyStateData.IsPropertyFlagged(property.GetIndex(), PropertyFlag.Null))
                {
                    var isSetDefault = foreignKey.DeleteBehavior is DeleteBehavior.SetDefault or DeleteBehavior.ClientSetDefault;

                    if (isSetDefault
                        || (properties.Any(p => p.IsNullable)
                            && foreignKey.DeleteBehavior != DeleteBehavior.Cascade
                            && foreignKey.DeleteBehavior != DeleteBehavior.ClientCascade))
                    {
                        foreach (var toNull in properties)
                        {
                            if (isSetDefault)
                            {
                                this[toNull] = toNull.Sentinel;
                            }
                            else if (toNull.IsNullable)
                            {
                                this[toNull] = null;
                            }
                            else
                            {
                                PropertyStateData.FlagProperty(toNull.GetIndex(), PropertyFlag.Null, isFlagged: false);
                            }
                        }
                    }
                    else if (EntityState != EntityState.Modified
                             || IsModified(property))
                    {
                        fks.Add(foreignKey);
                    }

                    break;