Table of Contents

Class IndexBuilder

Namespace
Microsoft.EntityFrameworkCore.Metadata.Builders
Assembly
Microsoft.EntityFrameworkCore.dll

Provides a simple API for configuring an IMutableIndex.

public class IndexBuilder : IInfrastructure<IConventionIndexBuilder>
Inheritance
IndexBuilder
Implements
Derived
Inherited Members
Extension Methods

Remarks

Instances of this class are returned from methods when using the ModelBuilder API and it is not designed to be directly constructed in your application code.

See Modeling entity types and relationships for more information and examples.

Constructors

IndexBuilder(IMutableIndex)

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

[EntityFrameworkInternal]
public IndexBuilder(IMutableIndex index)

Parameters

index IMutableIndex

Properties

Metadata

The index being configured.

public virtual IMutableIndex Metadata { get; }

Property Value

IMutableIndex

Methods

HasAnnotation(string, object?)

Adds or updates an annotation on the index. If an annotation with the key specified in annotation already exists its value will be updated.

public virtual IndexBuilder HasAnnotation(string annotation, object? value)

Parameters

annotation string

The key of the annotation to be added or updated.

value object

The value to be stored in the annotation.

Returns

IndexBuilder

The same builder instance so that multiple configuration calls can be chained.

IsDescending(params bool[])

Configures the sort order(s) for the columns of this index (ascending or descending).

public virtual IndexBuilder IsDescending(params bool[] descending)

Parameters

descending bool[]

A set of values indicating whether each corresponding index column has descending sort order. An empty list indicates that all index columns will have descending sort order.

Returns

IndexBuilder

The same builder instance so that multiple configuration calls can be chained.

IsUnique(bool)

Configures whether this index is unique (i.e. the value(s) for each instance must be unique).

public virtual IndexBuilder IsUnique(bool unique = true)

Parameters

unique bool

A value indicating whether this index is unique.

Returns

IndexBuilder

The same builder instance so that multiple configuration calls can be chained.