Repository: dotnet/efcore
File: test/EFCore.Specification.Tests/Query/AdHocComplexTypeQueryTestBase.cs (C#)

Code before:
    private class Context37162(DbContextOptions options) : DbContext(options)
    {
        protected override void OnModelCreating(ModelBuilder modelBuilder)
            => modelBuilder.Entity<EntityType>().ComplexProperty(b => b.NonOptionalComplexType);

        public class EntityType
        {
            public int Id { get; set; }
            public ComplexTypeWithAllNulls NonOptionalComplexType { get; set; } = null!;
        }

        public class ComplexTypeWithAllNulls
        {
            public string? NullableString { get; set; }
            public DateTime? NullableDateTime { get; set; }
        }
    }

    #endregion 37162

    #region Issue37634

    [ConditionalFact]
    public virtual async Task Nullable_complex_type_with_discriminator_and_shadow_property()
    {
        var contextFactory = await InitializeAsync<Context37634>(
            seed: context =>
            {
                context.Add(
                    new Context37634.EntityType
                    {
                        Prop = new Context37634.OptionalComplexProperty
                        {
                            OptionalValue = true
                        }
                    });
                return context.SaveChangesAsync();
            });

        await using var context = contextFactory.CreateContext();

        var entities = await context.Set<Context37634.EntityType>().ToArrayAsync();

        Assert.Single(entities);
        var entity = entities[0];
        Assert.NotNull(entity.Prop);
        Assert.True(entity.Prop.OptionalValue);
    }

    private class Context37634(DbContextOptions options) : DbContext(options)
    {

Review comment (suggestion):
The context factory initialization references "Context37634", but this should be "Context37337" to match the issue number being fixed. This is part of the broader naming inconsistency where the test uses issue #37634 instead of #37337.

Code after:
    private class Context37162(DbContextOptions options) : DbContext(options)
    {
        protected override void OnModelCreating(ModelBuilder modelBuilder)
            => modelBuilder.Entity<EntityType>().ComplexProperty(b => b.NonOptionalComplexType);

        public class EntityType
        {
            public int Id { get; set; }
            public ComplexTypeWithAllNulls NonOptionalComplexType { get; set; } = null!;
        }

        public class ComplexTypeWithAllNulls
        {
            public string? NullableString { get; set; }
            public DateTime? NullableDateTime { get; set; }
        }
    }

    #endregion 37162

    #region Issue37337

    [ConditionalFact]
    public virtual async Task Nullable_complex_type_with_discriminator_and_shadow_property()
    {
        var contextFactory = await InitializeAsync<Context37337>(
            seed: context =>
            {
                context.Add(
                    new Context37337.EntityType
                    {
                        Prop = new Context37337.OptionalComplexProperty
                        {
                            OptionalValue = true
                        }
                    });
                return context.SaveChangesAsync();
            });

        await using var context = contextFactory.CreateContext();

        var entities = await context.Set<Context37337.EntityType>().ToArrayAsync();

        Assert.Single(entities);
        var entity = entities[0];
        Assert.NotNull(entity.Prop);
        Assert.True(entity.Prop.OptionalValue);
    }

    private class Context37337(DbContextOptions options) : DbContext(options)
    {