TableBuilder<TColumns>.Index Method (Expression<Func<TColumns, Object>>, String, Boolean, Boolean, Object)

 

Specifies an index to be created on the table. Entity Framework Migrations APIs are not designed to accept input provided by untrusted sources (such as the end user of an application). If input is accepted from such sources it should be validated before being passed to these APIs to protect against SQL injection attacks etc.

Namespace:   System.Data.Entity.Migrations.Builders
Assembly:  EntityFramework (in EntityFramework.dll)

[SuppressMessageAttribute("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
[SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
[SuppressMessageAttribute("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
public TableBuilder<TColumns> Index(
	Expression<Func<TColumns, object>> indexExpression,
	string name = null,
	bool unique = false,
	bool clustered = false,
	object anonymousArguments = null
)

Parameters

indexExpression
Type: System.Linq.Expressions.Expression<Func<TColumns, Object>>

A lambda expression representing the property to be indexed. C#: t =&gt; t.PropertyOne VB.Net: Function(t) t.PropertyOne If multiple properties are to be indexed then specify an anonymous type including the properties. C#: t =&gt; new { t.PropertyOne, t.PropertyTwo } VB.Net: Function(t) New With { t.PropertyOne, t.PropertyTwo }

name
Type: System.String

The name of the index.

unique
Type: System.Boolean

A value indicating whether or not this is a unique index.

clustered
Type: System.Boolean

A value indicating whether or not this is a clustered index.

anonymousArguments
Type: System.Object

Additional arguments that may be processed by providers. Use anonymous type syntax to specify arguments e.g. 'new { SampleArgument = "MyValue" }'.

Return Value

Type: System.Data.Entity.Migrations.Builders.TableBuilder<TColumns>

Itself, so that multiple calls can be chained.