Skip to content

Commit 939cb0d

Browse files
alyioxroji
andauthored
Update indexes.md (#4950)
Co-authored-by: Shay Rojansky <[email protected]>
1 parent 4840014 commit 939cb0d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

entity-framework/core/modeling/indexes.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@ You can set the name of the index created in the database:
106106
Note that if you call `HasIndex` more than once on the same set of properties, that continues to configure a single index rather than create a new one:
107107

108108
```csharp
109-
modelBuilder.Entity<Blog>()
110-
.HasIndex(b => new { b.FirstName, b.LastName })
109+
modelBuilder.Entity<Person>()
110+
.HasIndex(p => new { p.FirstName, p.LastName })
111111
.HasDatabaseName("IX_Names_Ascending");
112112

113-
modelBuilder.Entity<Blog>()
114-
.HasIndex(b => new { b.FirstName, b.LastName })
113+
modelBuilder.Entity<Person>()
114+
.HasIndex(p => new { p.FirstName, p.LastName })
115115
.HasDatabaseName("IX_Names_Descending")
116116
.IsDescending();
117117
```
@@ -121,11 +121,11 @@ Since the second `HasIndex` call overrides the first one, this creates only a si
121121
To create multiple indexes over the same set of properties, pass a name to the `HasIndex`, which will be used to identify the index in the EF model, and to distinguish it from other indexes over the same properties:
122122

123123
```c#
124-
modelBuilder.Entity<Blog>()
125-
.HasIndex(b => new { b.FirstName, b.LastName }, "IX_Names_Ascending");
124+
modelBuilder.Entity<Person>()
125+
.HasIndex(p => new { p.FirstName, p.LastName }, "IX_Names_Ascending");
126126

127-
modelBuilder.Entity<Blog>()
128-
.HasIndex(b => new { b.FirstName, b.LastName }, "IX_Names_Descending")
127+
modelBuilder.Entity<Person>()
128+
.HasIndex(p => new { p.FirstName, p.LastName }, "IX_Names_Descending")
129129
.IsDescending();
130130
```
131131

0 commit comments

Comments
 (0)