Skip to content

Commit 31e551d

Browse files
authored
Add test for scaffolding multiple indexes on the same column (#25917)
Fixes #11846
1 parent fdbc2b9 commit 31e551d

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

test/EFCore.SqlServer.FunctionalTests/Scaffolding/SqlServerDatabaseModelFactoryTest.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,48 @@ CREATE TABLE IndexTable (
852852
"DROP TABLE IndexTable;");
853853
}
854854

855+
[ConditionalFact]
856+
public void Create_multiple_indexes_on_same_column()
857+
{
858+
Test(
859+
@"
860+
CREATE TABLE IndexTable (
861+
Id int,
862+
IndexProperty int
863+
);
864+
865+
CREATE INDEX IX_One on IndexTable ( IndexProperty ) WITH (FILLFACTOR = 100);
866+
CREATE INDEX IX_Two on IndexTable ( IndexProperty ) WITH (FILLFACTOR = 50);",
867+
Enumerable.Empty<string>(),
868+
Enumerable.Empty<string>(),
869+
dbModel =>
870+
{
871+
var table = dbModel.Tables.Single();
872+
873+
Assert.Equal(2, table.Indexes.Count);
874+
Assert.All(
875+
table.Indexes, c =>
876+
{
877+
Assert.Equal("dbo", c.Table.Schema);
878+
Assert.Equal("IndexTable", c.Table.Name);
879+
});
880+
881+
Assert.Collection(
882+
table.Indexes.OrderBy(i => i.Name),
883+
index =>
884+
{
885+
Assert.Equal("IX_One", index.Name);
886+
Assert.Equal(100, index[SqlServerAnnotationNames.FillFactor]);
887+
},
888+
index =>
889+
{
890+
Assert.Equal("IX_Two", index.Name);
891+
Assert.Equal(50, index[SqlServerAnnotationNames.FillFactor]);
892+
});
893+
},
894+
"DROP TABLE IndexTable;");
895+
}
896+
855897
[ConditionalFact]
856898
public void Create_foreign_keys()
857899
{

0 commit comments

Comments
 (0)