Repository: dotnet/efcore
File: src/EFCore.Relational/Design/AnnotationCodeGenerator.cs (C#)

Code before:
#pragma warning restore CS0618

            // Always generate the column type for JSON columns to ensure it's captured in the snapshot
            if (annotations.TryGetValue(RelationalAnnotationNames.ContainerColumnType, out var containerColumnTypeAnnotation)
                && containerColumnTypeAnnotation is { Value: string containerColumnType })
            {
                methodCallCodeFragments.Add(
                    new MethodCallCodeFragment(
                        nameof(RelationalOwnedNavigationBuilderExtensions.HasColumnType),
                        containerColumnType));

                annotations.Remove(RelationalAnnotationNames.ContainerColumnType);
            }
            else
            {
                // If no explicit column type is set, use the default from the type mapping source
                var typeMapping = Dependencies.RelationalTypeMappingSource.FindMapping(typeof(string));
                if (typeMapping != null)
                {
                    methodCallCodeFragments.Add(
                        new MethodCallCodeFragment(
                            nameof(RelationalOwnedNavigationBuilderExtensions.HasColumnType),
                            typeMapping.StoreType));
                }
            }
        }
        else if (annotations.TryGetValue(RelationalAnnotationNames.ContainerColumnType, out var containerColumnTypeAnnotation)
            && containerColumnTypeAnnotation is { Value: string containerColumnType }
            && entityType.IsOwned())
        {
            methodCallCodeFragments.Add(
                new MethodCallCodeFragment(
                    nameof(RelationalOwnedNavigationBuilderExtensions.HasColumnType),
                    containerColumnType));

            annotations.Remove(RelationalAnnotationNames.ContainerColumnType);
        }

        if (annotations.TryGetValue(RelationalAnnotationNames.JsonPropertyName, out var jsonPropertyNameAnnotation)
            && jsonPropertyNameAnnotation is { Value: string jsonPropertyName }
            && entityType.IsOwned())
        {
            methodCallCodeFragments.Add(
                new MethodCallCodeFragment(
                    nameof(RelationalOwnedNavigationBuilderExtensions.HasJsonPropertyName),
                    jsonPropertyName));

            annotations.Remove(RelationalAnnotationNames.JsonPropertyName);
        }

        methodCallCodeFragments.AddRange(GenerateFluentApiCallsHelper(entityType, annotations, GenerateFluentApi));

Review comment (suggestion):
@copilot Instead of doing it here, add code to CSharpSnapshotGenerator.GeneratePropertyAnnotations to add the annotation if missing

Code after:
#pragma warning restore CS0618
        }

        if (annotations.TryGetValue(RelationalAnnotationNames.ContainerColumnType, out var containerColumnTypeAnnotation)
            && containerColumnTypeAnnotation is { Value: string containerColumnType }
            && entityType.IsOwned())
        {
            methodCallCodeFragments.Add(
                new MethodCallCodeFragment(
                    nameof(RelationalOwnedNavigationBuilderExtensions.HasColumnType),
                    containerColumnType));

            annotations.Remove(RelationalAnnotationNames.ContainerColumnType);
        }

        if (annotations.TryGetValue(RelationalAnnotationNames.JsonPropertyName, out var jsonPropertyNameAnnotation)
            && jsonPropertyNameAnnotation is { Value: string jsonPropertyName }
            && entityType.IsOwned())
        {
            methodCallCodeFragments.Add(
                new MethodCallCodeFragment(
                    nameof(RelationalOwnedNavigationBuilderExtensions.HasJsonPropertyName),
                    jsonPropertyName));

            annotations.Remove(RelationalAnnotationNames.JsonPropertyName);
        }

        methodCallCodeFragments.AddRange(GenerateFluentApiCallsHelper(entityType, annotations, GenerateFluentApi));

        return methodCallCodeFragments;
    }

    /// <inheritdoc />
    public virtual IReadOnlyList<MethodCallCodeFragment> GenerateFluentApiCalls(
        IComplexType complexType,
        IDictionary<string, IAnnotation> annotations)
    {
        var methodCallCodeFragments = new List<MethodCallCodeFragment>();

        if (annotations.TryGetValue(RelationalAnnotationNames.ContainerColumnName, out var containerColumnNameAnnotation)
            && containerColumnNameAnnotation is { Value: string containerColumnName })
        {
            methodCallCodeFragments.Add(
                new MethodCallCodeFragment(
                    nameof(RelationalComplexPropertyBuilderExtensions.ToJson),
                    containerColumnName));

            annotations.Remove(RelationalAnnotationNames.ContainerColumnName);
#pragma warning disable CS0618
            annotations.Remove(RelationalAnnotationNames.ContainerColumnTypeMapping);
#pragma warning restore CS0618