Skip to main content

Commands: Indexes: How to check if an index has changed?

IndexHasChanged will let you check if the given index definition differs from the one on a server. This might be useful when you want to check the prior index deployment, if index will be overwritten, and if indexing data will be lost.

Syntax

bool IndexHasChanged(string name, IndexDefinition indexDef);
Parameters
namestringname of an index to check
indexDefIndexDefinitionindex definition
Return Value
trueif an index does not exist on a server
trueif an index definition does not match the one from the indexDef parameter
falseif there are no differences between an index definition on server and the one from the indexDef parameter

Example

store.DatabaseCommands.IndexHasChanged("Orders/Totals", indexDefinition);