Indices with SchemaBuilder

Topics: Writing modules
Sep 28, 2011 at 12:18 PM

Hi all!

Is there a way to declare indices on columns in a migration class with SchemaBuilder? It seems that there is no such option. Does that mean that if I query for a specific column (which is not the primary key) SQL Server makes a full table scan?

Sep 28, 2011 at 3:41 PM
Edited Sep 28, 2011 at 3:47 PM

You can actually define an Index with SchemaBuilder using AlterTable method, ie:

table => table
  .Column<int>("Id", column => column.PrimaryKey().Identity())
table => table

Method signature:
AlterTableCommand.CreateIndex(string indexName, params string[] columnNames);
Sep 29, 2011 at 7:47 AM

Thank you a lot, I didn't looked in AlterTable...