Repository: dotnet/efcore
File: test/EFCore.SqlServer.FunctionalTests/Migrations/MigrationsSqlServerTest.TemporalTables.cs (C#)

Code before:
        AssertSql(
            """
EXEC sp_rename N'[Customers].[Name]', N'NewName', 'COLUMN';
""",
            //
            """
ALTER TABLE [Customers] SET (SYSTEM_VERSIONING = OFF)
""",
            //
            """
DROP TABLE [Customers];
""",
            //
            """
DROP TABLE [historySchema].[HistoryTable];
""",
            //
            """
CREATE TABLE [Customers] (
    [Id] int NOT NULL IDENTITY,
    [Name] nvarchar(max) NULL,
    CONSTRAINT [PK_Customers] PRIMARY KEY ([Id])
);
""");
    }

    [ConditionalFact]
    public virtual async Task Temporal_table_with_default_constraint_can_alter_column()
    {
        await Test(
            builder => { },
            builder => builder.Entity(
                "Customer", e =>
                {
                    e.Property<int>("Id").ValueGeneratedOnAdd();
                    e.Property<string>("Name").HasMaxLength(50).HasDefaultValue("DefaultName");
                    e.Property<DateTime>("SystemTimeStart").ValueGeneratedOnAddOrUpdate();
                    e.Property<DateTime>("SystemTimeEnd").ValueGeneratedOnAddOrUpdate();
                    e.HasKey("Id");

                    e.ToTable(tb => tb.IsTemporal(ttb =>
                    {
                        ttb.HasPeriodStart("SystemTimeStart");
                        ttb.HasPeriodEnd("SystemTimeEnd");
                    }));
                }),
            builder => builder.Entity(
                "Customer", e =>
                {
                    e.Property<int>("Id").ValueGeneratedOnAdd();
                    e.Property<string>("Name").HasMaxLength(100); // Remove default value

Review comment (suggestion):
Also add a test that removes `HasDefaultValueSql`.
In all the new tests move the common code between source and target models to the first argument of `Test` method

Code after:
        AssertSql(
            """
EXEC sp_rename N'[Customers].[Name]', N'NewName', 'COLUMN';
""",
            //
            """
ALTER TABLE [Customers] SET (SYSTEM_VERSIONING = OFF)
""",
            //
            """
DROP TABLE [Customers];
""",
            //
            """
DROP TABLE [historySchema].[HistoryTable];
""",
            //
            """
CREATE TABLE [Customers] (
    [Id] int NOT NULL IDENTITY,
    [Name] nvarchar(max) NULL,
    CONSTRAINT [PK_Customers] PRIMARY KEY ([Id])
);
""");
    }

    [ConditionalFact]
    public virtual async Task Temporal_table_with_default_constraint_can_alter_column()
    {
        await Test(
            builder => builder.Entity(
                "Customer", e =>
                {
                    e.Property<int>("Id").ValueGeneratedOnAdd();
                    e.Property<DateTime>("SystemTimeStart").ValueGeneratedOnAddOrUpdate();
                    e.Property<DateTime>("SystemTimeEnd").ValueGeneratedOnAddOrUpdate();
                    e.HasKey("Id");

                    e.ToTable(tb => tb.IsTemporal(ttb =>
                    {
                        ttb.HasPeriodStart("SystemTimeStart");
                        ttb.HasPeriodEnd("SystemTimeEnd");
                    }));
                }),
            builder => builder.Entity(
                "Customer", e =>
                {
                    e.Property<string>("Name").HasMaxLength(50).HasDefaultValue("DefaultName");
                }),
            builder => builder.Entity(
                "Customer", e =>