This project is read-only.

Indices with SchemaBuilder

Topics: Writing modules
Sep 28, 2011 at 1: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 4:41 PM
Edited Sep 28, 2011 at 4: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 8:47 AM

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