Repository: dotnet/efcore
File: test/EFCore.Tests/ChangeTracking/Internal/PropertyValuesTest.cs (C#)

Code before:
        var original = entry.OriginalValues.ToObject() as BlogWithTags;
        
        Assert.NotNull(original);
        Assert.Equal("Test Blog", original.Title);
        Assert.NotNull(original.Tags);
        Assert.Equal(3, original.Tags.Count);
        
        // Verify Tag1 (null Metadata)
        Assert.Equal("Tag1", original.Tags[0].Name);
        Assert.Null(original.Tags[0].Metadata);
        
        // Verify Tag2 (Metadata populated but InnerData is null)
        Assert.Equal("Tag2", original.Tags[1].Name);
        Assert.NotNull(original.Tags[1].Metadata);
        Assert.Equal("AuthorA", original.Tags[1].Metadata.Author);
        Assert.Null(original.Tags[1].Metadata.InnerData);
        
        // Verify Tag3 (fully populated)
        Assert.Equal("Tag3", original.Tags[2].Name);
        Assert.NotNull(original.Tags[2].Metadata);
        Assert.Equal("AuthorB", original.Tags[2].Metadata.Author);
        Assert.NotNull(original.Tags[2].Metadata.InnerData);
        Assert.Equal("SourceX", original.Tags[2].Metadata.InnerData.Source);
    }

    private class BlogWithTags
    {
        public int Id { get; set; }
        public string Title { get; set; }
        public List<TagWithMetadata> Tags { get; set; }
    }

    private class TagWithMetadata
    {
        public string Name { get; set; }
        public TagMetadata Metadata { get; set; }
    }

    private class TagMetadata
    {
        public string Author { get; set; }
        public string CreatedDate { get; set; }
        public InnerMetadata InnerData { get; set; }
    }

    private class InnerMetadata
    {
        public string Source { get; set; }
    }

    [ConditionalFact]

Review comment (suggestion):
@copilot Add a `JobError` collection to `Job` and use it instead of adding these classes

Code after:
                    Code = "503",
                    Message = "Service Unavailable",
                    InnerError = new JobError
                    {
                        Code = "504",
                        Message = "Gateway Timeout",
                        InnerError = new LeafJobError { Code = "505", Message = "Internal Error" }
                    }
                }
            ]
        };

        var result = GetToObjectResult(job, useOriginalValues);

        Assert.Equal("Test Job", result.Name);
        Assert.Null(result.Error);
        Assert.NotNull(result.Errors);
        Assert.Equal(3, result.Errors.Count);

        Assert.Equal("400", result.Errors[0].Code);
        Assert.Equal("Bad Request", result.Errors[0].Message);
        Assert.Null(result.Errors[0].InnerError);

        Assert.Equal("500", result.Errors[1].Code);
        Assert.Equal("Server Error", result.Errors[1].Message);
        Assert.NotNull(result.Errors[1].InnerError);
        Assert.Equal("501", result.Errors[1].InnerError!.Code);
        Assert.Null(result.Errors[1].InnerError!.InnerError);

        Assert.Equal("503", result.Errors[2].Code);
        Assert.NotNull(result.Errors[2].InnerError);
        Assert.Equal("504", result.Errors[2].InnerError!.Code);
        Assert.NotNull(result.Errors[2].InnerError!.InnerError);
        Assert.Equal("505", result.Errors[2].InnerError!.InnerError!.Code);
    }

    [ConditionalTheory]
    [ClassData(typeof(DataGenerator<bool>))]
    public void ToObject_with_null_complex_property_in_complex_collection_in_complex_collection(
        bool? useOriginalValues)
    {
        var job = new Job
        {
            Id = 1,
            Name = "Double Collection Test",
            Errors =
            [
                new RootJobError
                {
                    Code = "400",
                    Message = "Bad Request",