Class IndexBuilder<T>
- Namespace
- Microsoft.EntityFrameworkCore.Metadata.Builders
- Assembly
- Microsoft.EntityFrameworkCore.dll
Provides a simple API for configuring an IMutableIndex.
public class IndexBuilder<T> : IndexBuilder, IInfrastructure<IConventionIndexBuilder>
Type Parameters
T
- Inheritance
-
IndexBuilder<T>
- Implements
- 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
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<T> HasAnnotation(string annotation, object? value)
Parameters
annotation
stringThe key of the annotation to be added or updated.
value
objectThe value to be stored in the annotation.
Returns
- IndexBuilder<T>
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<T> 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<T>
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<T> IsUnique(bool unique = true)
Parameters
unique
boolA value indicating whether this index is unique.
Returns
- IndexBuilder<T>
The same builder instance so that multiple configuration calls can be chained.