IndexAttribute IndexAttribute 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
IndexAttributeIndexAttributeIndexAttribute
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() IndexAttribute() 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) IndexAttribute(String) 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) IndexAttribute(String, Int32) 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 IsClustered IsClustered

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

IsClusteredConfigured IsClusteredConfigured IsClusteredConfigured

Returns true if IsClustered has been set to a value.

IsUnique IsUnique IsUnique

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

IsUniqueConfigured IsUniqueConfigured IsUniqueConfigured

Returns true if IsUnique has been set to a value.

Name Name Name

The index name.

Order Order 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 TypeId 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) Equals(IndexAttribute) Equals(IndexAttribute)

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

Equals(Object) Equals(Object) Equals(Object)

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

GetHashCode() GetHashCode() GetHashCode()
ToString() ToString() ToString()

Applies to