IndexAttribute Class

Definition

When this attribute is placed on a property it indicates that the database column to which the property is mapped has an index.

[System.AttributeUsage(System.AttributeTargets.Property, AllowMultiple=true)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments")]
public class IndexAttribute : Attribute
type IndexAttribute = class
    inherit Attribute
Public Class IndexAttribute
Inherits Attribute
Inheritance
IndexAttribute
Attributes

Remarks

This attribute is used by Entity Framework Migrations to create indexes on mapped database columns. Multi-column indexes are created by using the same index name in multiple attributes. The information in these attributes is then merged together to specify the actual database index.

Constructors

IndexAttribute()

Creates a IndexAttribute instance for an index that will be named by convention and has no column order, clustering, or uniqueness specified.

IndexAttribute(String)

Creates a IndexAttribute instance for an index with the given name and has no column order, clustering, or uniqueness specified.

IndexAttribute(String, Int32)

Creates a IndexAttribute instance for an index with the given name and column order, but with no clustering or uniqueness specified.

Properties

IsClustered

Set this property to true to define a clustered index. Set this property to false to define a non-clustered index.

IsClusteredConfigured

Returns true if IsClustered has been set to a value.

IsUnique

Set this property to true to define a unique index. Set this property to false to define a non-unique index.

IsUniqueConfigured

Returns true if IsUnique has been set to a value.

Name

The index name.

Order

A number which will be used to determine column ordering for multi-column indexes. This will be -1 if no column order has been specified.

TypeId

Returns a different ID for each object instance such that type descriptors won't attempt to combine all IndexAttribute instances into a single instance.

Methods

Equals(IndexAttribute)

Returns true if this attribute specifies the same name and configuration as the given attribute.

Equals(Object)

Returns true if this attribute specifies the same name and configuration as the given attribute.

GetHashCode()

Returns the hash code for this instance.

ToString() System.Attribute.ToString

Applies to