Repository: dotnet/efcore
File: test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.ModelSnapshot.cs (C#)

Code before:
                var ownership3 = navigation3.ForeignKey;
                Assert.Equal("EntityWithStringKeyEntityWithTwoPropertiesEntityWithOnePropertyId", ownership3.Properties[0].Name);
                Assert.Equal(nameof(EntityWithStringKey.Properties), ownership3.PrincipalToDependent.Name);
                Assert.True(ownership3.IsRequired);
                Assert.False(ownership3.IsUnique);

                var ownedType3 = ownership3.DeclaringEntityType;
                Assert.Equal(nameof(EntityWithStringProperty), ownedType3.DisplayName());
                var pkProperties3 = ownedType3.FindPrimaryKey().Properties;
                Assert.Equal("EntityWithStringKeyEntityWithTwoPropertiesEntityWithOnePropertyId", pkProperties3[0].Name);
                Assert.Equal("__synthesizedOrdinal", pkProperties3[1].Name);

                var ownedProperties3 = ownedType3.GetProperties().ToList();
                Assert.Equal(4, ownedProperties3.Count);

                Assert.Equal("EntityWithStringKeyEntityWithTwoPropertiesEntityWithOnePropertyId", ownedProperties3[0].Name);
                Assert.Equal("__synthesizedOrdinal", ownedProperties3[1].Name);
                Assert.Equal("Id", ownedProperties3[2].Name);
                Assert.Equal("Name", ownedProperties3[3].Name);
            });

    [ConditionalFact]
    public virtual void Owned_types_mapped_to_json_with_explicit_column_type_are_stored_in_snapshot()
        => Test(
            builder =>
            {
                builder.Entity<EntityWithOneProperty>(b =>
                {
                    b.HasKey(x => x.Id).HasName("PK_Custom");

                    b.OwnsOne(
                        x => x.EntityWithTwoProperties, bb =>
                        {
                            bb.ToJson().HasColumnType("json");
                            bb.Ignore(x => x.Id);
                            bb.Property(x => x.AlternateId).HasJsonPropertyName("NotKey");
                            bb.WithOwner(e => e.EntityWithOneProperty);
                        });
                });
            },
            AddBoilerPlate(
                GetHeading()
                + """
            modelBuilder.Entity("Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGeneratorTest+EntityWithOneProperty", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("int");

                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));


Review comment (suggestion):
@copilot I see the issue, the column type is not generated in the snapshot if it has the default value. Fix the issue and modify `Owned_types_mapped_to_json_are_stored_in_snapshot` to expect `.HasColumnType("nvarchar(max)");` to be generated in the snapshot. Also, rename `Complex_types_mapped_to_json_are_stored_in_snapshot` to `Complex_types_mapped_to_json_with_explicit_column_type_are_stored_in_snapshot` and add `Complex_types_mapped_to_json_are_stored_in_snapshot` that doesn't specify an explicit column type, but expects it in the model.

Code after:

                var navigation3 = ownedType2.FindNavigation(nameof(EntityWithStringKey.Properties));
                Assert.Equal("JsonProps", navigation3.TargetEntityType.GetJsonPropertyName());
                var ownership3 = navigation3.ForeignKey;
                Assert.Equal("EntityWithStringKeyEntityWithTwoPropertiesEntityWithOnePropertyId", ownership3.Properties[0].Name);
                Assert.Equal(nameof(EntityWithStringKey.Properties), ownership3.PrincipalToDependent.Name);
                Assert.True(ownership3.IsRequired);
                Assert.False(ownership3.IsUnique);

                var ownedType3 = ownership3.DeclaringEntityType;
                Assert.Equal(nameof(EntityWithStringProperty), ownedType3.DisplayName());
                var pkProperties3 = ownedType3.FindPrimaryKey().Properties;
                Assert.Equal("EntityWithStringKeyEntityWithTwoPropertiesEntityWithOnePropertyId", pkProperties3[0].Name);
                Assert.Equal("__synthesizedOrdinal", pkProperties3[1].Name);

                var ownedProperties3 = ownedType3.GetProperties().ToList();
                Assert.Equal(4, ownedProperties3.Count);

                Assert.Equal("EntityWithStringKeyEntityWithTwoPropertiesEntityWithOnePropertyId", ownedProperties3[0].Name);
                Assert.Equal("__synthesizedOrdinal", ownedProperties3[1].Name);
                Assert.Equal("Id", ownedProperties3[2].Name);
                Assert.Equal("Name", ownedProperties3[3].Name);
            });

    [ConditionalFact]
    public virtual void Owned_types_mapped_to_json_with_explicit_column_type_are_stored_in_snapshot()
        => Test(
            builder =>
            {
                builder.Entity<EntityWithOneProperty>(b =>
                {
                    b.HasKey(x => x.Id).HasName("PK_Custom");

                    b.OwnsOne(
                        x => x.EntityWithTwoProperties, bb =>
                        {
                            bb.ToJson().HasColumnType("json");
                            bb.Ignore(x => x.Id);
                            bb.Property(x => x.AlternateId).HasJsonPropertyName("NotKey");
                            bb.WithOwner(e => e.EntityWithOneProperty);
                        });
                });
            },
            AddBoilerPlate(
                GetHeading()
                + """
            modelBuilder.Entity("Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGeneratorTest+EntityWithOneProperty", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("int");