奇怪的是我在任何地方都找不到关于这个的例子或提及。我想使用流畅的API在两列上设置索引(不是复合索引,只是两个单独的索引)。
例如,我想知道是否可以做类似这样的事情:
modelBuilder.Entity<T>
.HasIndex(h => h.Column1)
.HasIndex(h => h.Column2);
然而,从外观来看,不可能像这样链式地连接索引。目前我所做的是分别设置它们,如下所示:
modelBuilder.Entity<T>
.HasIndex(h => h.Column1)
modelBuilder.Entity<T>
.HasIndex(h => h.Column2)
有更好的方法吗?