Repository: dotnet/efcore
File: src/EFCore.Design/Migrations/Design/CSharpSnapshotGenerator.cs (C#)

Code before:
                case CoreAnnotationNames.DiscriminatorProperty:
                    discriminatorPropertyAnnotation = annotation;
                    break;
                case CoreAnnotationNames.DiscriminatorValue:
                    discriminatorValueAnnotation = annotation;
                    break;
                case CoreAnnotationNames.DiscriminatorMappingComplete:
                    discriminatorMappingCompleteAnnotation = annotation;
                    break;
            }
        }

        var annotations = Dependencies.AnnotationCodeGenerator
            .FilterIgnoredAnnotations(entityType.GetAnnotations())
            .ToDictionary(a => a.Name, a => a);

        // Add ContainerColumnType annotation if entity is mapped to JSON but the type annotation is missing
        if (annotations.ContainsKey(RelationalAnnotationNames.ContainerColumnName)
            && !annotations.ContainsKey(RelationalAnnotationNames.ContainerColumnType))
        {
            var typeMapping = Dependencies.RelationalTypeMappingSource.FindMapping(typeof(string));
            if (typeMapping != null)
            {
                annotations[RelationalAnnotationNames.ContainerColumnType] = new Annotation(
                    RelationalAnnotationNames.ContainerColumnType,
                    typeMapping.StoreType);
            }
        }

        GenerateTableMapping(entityTypeBuilderName, entityType, stringBuilder, annotations);
        GenerateSplitTableMapping(entityTypeBuilderName, entityType, stringBuilder);

        GenerateViewMapping(entityTypeBuilderName, entityType, stringBuilder, annotations);
        GenerateSplitViewMapping(entityTypeBuilderName, entityType, stringBuilder);

        var functionNameAnnotation = annotations.Find(RelationalAnnotationNames.FunctionName);
        if (functionNameAnnotation != null
            || entityType.BaseType == null)
        {
            var functionName = (string?)functionNameAnnotation?.Value ?? entityType.GetFunctionName();
            if (functionName != null
                || functionNameAnnotation != null)
            {
                stringBuilder
                    .AppendLine()
                    .Append(entityTypeBuilderName)
                    .Append(".ToFunction(")
                    .Append(Code.Literal(functionName))
                    .AppendLine(");");
                if (functionNameAnnotation != null)
                {

Review comment (suggestion):
@copilot Use `property.ComplexType.GetContainerColumnType()` instead, also use equivalent code for owned entity types above.

Code after:
            {
                case CoreAnnotationNames.DiscriminatorProperty:
                    discriminatorPropertyAnnotation = annotation;
                    break;
                case CoreAnnotationNames.DiscriminatorValue:
                    discriminatorValueAnnotation = annotation;
                    break;
                case CoreAnnotationNames.DiscriminatorMappingComplete:
                    discriminatorMappingCompleteAnnotation = annotation;
                    break;
            }
        }

        var annotations = Dependencies.AnnotationCodeGenerator
            .FilterIgnoredAnnotations(entityType.GetAnnotations())
            .ToDictionary(a => a.Name, a => a);

        // Add ContainerColumnType annotation if entity is mapped to JSON but the type annotation is missing
        if (annotations.ContainsKey(RelationalAnnotationNames.ContainerColumnName)
            && !annotations.ContainsKey(RelationalAnnotationNames.ContainerColumnType))
        {
            var containerColumnType = entityType.GetContainerColumnType()
                ?? Dependencies.RelationalTypeMappingSource.FindMapping(typeof(JsonTypePlaceholder))?.StoreType;
            if (containerColumnType != null)
            {
                annotations[RelationalAnnotationNames.ContainerColumnType] = new Annotation(
                    RelationalAnnotationNames.ContainerColumnType,
                    containerColumnType);
            }
        }

        GenerateTableMapping(entityTypeBuilderName, entityType, stringBuilder, annotations);
        GenerateSplitTableMapping(entityTypeBuilderName, entityType, stringBuilder);

        GenerateViewMapping(entityTypeBuilderName, entityType, stringBuilder, annotations);
        GenerateSplitViewMapping(entityTypeBuilderName, entityType, stringBuilder);

        var functionNameAnnotation = annotations.Find(RelationalAnnotationNames.FunctionName);
        if (functionNameAnnotation != null
            || entityType.BaseType == null)
        {
            var functionName = (string?)functionNameAnnotation?.Value ?? entityType.GetFunctionName();
            if (functionName != null
                || functionNameAnnotation != null)
            {
                stringBuilder
                    .AppendLine()
                    .Append(entityTypeBuilderName)
                    .Append(".ToFunction(")
                    .Append(Code.Literal(functionName))
                    .AppendLine(");");