Share via


TableBuilder<TColumns>.PrimaryKey Method

Definition

Overloads

PrimaryKey(Expression<Func<TColumns,Object>>, String, Object)

Specifies a primary key for the table.

PrimaryKey(Expression<Func<TColumns,Object>>, String, Boolean, Object)

Specifies a primary key for 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.

PrimaryKey(Expression<Func<TColumns,Object>>, String, Object)

Specifies a primary key for the table.

public System.Data.Entity.Migrations.Builders.TableBuilder<TColumns> PrimaryKey (System.Linq.Expressions.Expression<Func<TColumns,object>> keyExpression, string name = null, object anonymousArguments = null);
member this.PrimaryKey : System.Linq.Expressions.Expression<Func<'Columns, obj>> * string * obj -> System.Data.Entity.Migrations.Builders.TableBuilder<'Columns>
Public Function PrimaryKey (keyExpression As Expression(Of Func(Of TColumns, Object)), Optional name As String = null, Optional anonymousArguments As Object = null) As TableBuilder(Of TColumns)

Parameters

keyExpression
Expression<Func<TColumns,Object>>

A lambda expression representing the property to be used as the primary key. C#: t => t.Id
VB.Net: Function(t) t.Id

If the primary key is made up of multiple properties then specify an anonymous type including the properties. C#: t => new { t.Id1, t.Id2 } VB.Net: Function(t) New With { t.Id1, t.Id2 }

name
String

The name of the primary key. If null is supplied, a default name will be generated.

anonymousArguments
Object

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

Returns

Itself, so that multiple calls can be chained.

Applies to

PrimaryKey(Expression<Func<TColumns,Object>>, String, Boolean, Object)

Specifies a primary key for 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.

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
public System.Data.Entity.Migrations.Builders.TableBuilder<TColumns> PrimaryKey (System.Linq.Expressions.Expression<Func<TColumns,object>> keyExpression, string name = null, bool clustered = true, object anonymousArguments = null);
member this.PrimaryKey : System.Linq.Expressions.Expression<Func<'Columns, obj>> * string * bool * obj -> System.Data.Entity.Migrations.Builders.TableBuilder<'Columns>
Public Function PrimaryKey (keyExpression As Expression(Of Func(Of TColumns, Object)), Optional name As String = null, Optional clustered As Boolean = true, Optional anonymousArguments As Object = null) As TableBuilder(Of TColumns)

Parameters

keyExpression
Expression<Func<TColumns,Object>>

A lambda expression representing the property to be used as the primary key. C#: t => t.Id VB.Net: Function(t) t.Id If the primary key is made up of multiple properties then specify an anonymous type including the properties. C#: t => new { t.Id1, t.Id2 } VB.Net: Function(t) New With { t.Id1, t.Id2 }

name
String

The name of the primary key. If null is supplied, a default name will be generated.

clustered
Boolean

A value indicating whether or not this is a clustered primary key.

anonymousArguments
Object

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

Returns

Itself, so that multiple calls can be chained.

Attributes

Applies to