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

Code before:
                Assert.False(column.IsNullable);
                var index = Assert.Single(table.Indexes);
                Assert.Equal(1, index.Columns.Count);
                Assert.Contains(table.Columns.Single(c => c.Name == "SomeColumn"), index.Columns);
                var includedColumns = (IReadOnlyList<string>?)index[SqlServerAnnotationNames.Include];
                Assert.Null(includedColumns);
            });

        AssertSql(
            """
DROP INDEX [IX_People_SomeColumn] ON [People];
DECLARE @var nvarchar(max);
SELECT @var = QUOTENAME([d].[name])
FROM [sys].[default_constraints] [d]
INNER JOIN [sys].[columns] [c] ON [d].[parent_column_id] = [c].[column_id] AND [d].[parent_object_id] = [c].[object_id]
WHERE ([d].[parent_object_id] = OBJECT_ID(N'[People]') AND [c].[name] = N'SomeColumn');
IF @var IS NOT NULL EXEC(N'ALTER TABLE [People] DROP CONSTRAINT ' + @var + ';');
UPDATE [People] SET [SomeColumn] = N'' WHERE [SomeColumn] IS NULL;
ALTER TABLE [People] ALTER COLUMN [SomeColumn] nvarchar(450) NOT NULL;
ALTER TABLE [People] ADD DEFAULT N'' FOR [SomeColumn];
CREATE INDEX [IX_People_SomeColumn] ON [People] ([SomeColumn]) INCLUDE ([SomeOtherColumn]);
""");
    }

    [ConditionalFact, SqlServerCondition(SqlServerCondition.SupportsMemoryOptimized)]
    [PlatformSkipCondition(TestUtilities.Xunit.TestPlatform.Mac)] // TODO: see #37647
    public virtual async Task Alter_column_memoryOptimized_with_index()
    {
        await Test(
            builder => builder.Entity(
                "People", e =>
                {
                    e.ToTable(tb => tb.IsMemoryOptimized());
                    e.Property<int>("Id");
                    e.Property<string>("Name");
                    e.HasKey("Id").IsClustered(false);
                    e.HasIndex("Name").IsClustered(false);
                }),
            builder => { },
            builder => builder.Entity("People").Property<string>("Name").HasMaxLength(30),
            model =>
            {
                var table = Assert.Single(model.Tables);
                var column = Assert.Single(table.Columns, c => c.Name == "Name");
                Assert.Equal("nvarchar(30)", column.StoreType);
            });

        AssertSql(
            """
ALTER TABLE [People] DROP INDEX [IX_People_Name];
DECLARE @var2 nvarchar(max);

Review comment (bug):
Consider setting `SkipReason` on `PlatformSkipCondition` (e.g. mentioning #37647 and the SQL Server crash under Rosetta). Otherwise the test runner will report the generic default skip reason and the inline `// TODO` comment won’t show up in CI results.
```suggestion
    [PlatformSkipCondition(
        TestUtilities.Xunit.TestPlatform.Mac,
        SkipReason = "See #37647: SQL Server crash under Rosetta on macOS")]
```

Code after:
                var table = Assert.Single(model.Tables);
                var column = Assert.Single(table.Columns, c => c.Name == "SomeColumn");
                Assert.False(column.IsNullable);
                var index = Assert.Single(table.Indexes);
                Assert.Equal(1, index.Columns.Count);
                Assert.Contains(table.Columns.Single(c => c.Name == "SomeColumn"), index.Columns);
                var includedColumns = (IReadOnlyList<string>?)index[SqlServerAnnotationNames.Include];
                Assert.Null(includedColumns);
            });

        AssertSql(
            """
DROP INDEX [IX_People_SomeColumn] ON [People];
DECLARE @var nvarchar(max);
SELECT @var = QUOTENAME([d].[name])
FROM [sys].[default_constraints] [d]
INNER JOIN [sys].[columns] [c] ON [d].[parent_column_id] = [c].[column_id] AND [d].[parent_object_id] = [c].[object_id]
WHERE ([d].[parent_object_id] = OBJECT_ID(N'[People]') AND [c].[name] = N'SomeColumn');
IF @var IS NOT NULL EXEC(N'ALTER TABLE [People] DROP CONSTRAINT ' + @var + ';');
UPDATE [People] SET [SomeColumn] = N'' WHERE [SomeColumn] IS NULL;
ALTER TABLE [People] ALTER COLUMN [SomeColumn] nvarchar(450) NOT NULL;
ALTER TABLE [People] ADD DEFAULT N'' FOR [SomeColumn];
CREATE INDEX [IX_People_SomeColumn] ON [People] ([SomeColumn]) INCLUDE ([SomeOtherColumn]);
""");
    }

    [ConditionalFact, SqlServerCondition(SqlServerCondition.SupportsMemoryOptimized)]
    [PlatformSkipCondition(
        TestUtilities.Xunit.TestPlatform.Mac,
        SkipReason = "SQL Server crashes under Rosetta on macOS; see #37647")]
    public virtual async Task Alter_column_memoryOptimized_with_index()
    {
        await Test(
            builder => builder.Entity(
                "People", e =>
                {
                    e.ToTable(tb => tb.IsMemoryOptimized());
                    e.Property<int>("Id");
                    e.Property<string>("Name");
                    e.HasKey("Id").IsClustered(false);
                    e.HasIndex("Name").IsClustered(false);
                }),
            builder => { },
            builder => builder.Entity("People").Property<string>("Name").HasMaxLength(30),
            model =>
            {
                var table = Assert.Single(model.Tables);
                var column = Assert.Single(table.Columns, c => c.Name == "Name");
                Assert.Equal("nvarchar(30)", column.StoreType);
            });