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

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

        AssertSql(
            """
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'Name');
IF @var IS NOT NULL EXEC(N'ALTER TABLE [People] DROP CONSTRAINT ' + @var + ';');
ALTER TABLE [People] ALTER COLUMN [Name] nvarchar(450) NOT NULL;
""",
//
            $"""
CREATE UNIQUE INDEX [IX_People_Name] ON [People] ([Name]) INCLUDE ([FirstName], [LastName]) WITH (SORT_IN_TEMPDB = ON, DATA_COMPRESSION = {dataCompressionSql});
""");
    }

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

        AssertSql(
            """
DECLARE @var2 nvarchar(max);
SELECT @var2 = QUOTENAME([d].[name])

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 crashes under Rosetta on macOS.")]
```

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

        AssertSql(
            """
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'Name');
IF @var IS NOT NULL EXEC(N'ALTER TABLE [People] DROP CONSTRAINT ' + @var + ';');
ALTER TABLE [People] ALTER COLUMN [Name] nvarchar(450) NOT NULL;
""",
//
            $"""
CREATE UNIQUE INDEX [IX_People_Name] ON [People] ([Name]) INCLUDE ([FirstName], [LastName]) WITH (SORT_IN_TEMPDB = ON, DATA_COMPRESSION = {dataCompressionSql});
""");
    }

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