DbMigration.AddPrimaryKey Method

 

Adds an operation to create a new primary key.

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

NameDescription
System_CAPS_protmethodAddPrimaryKey(String, String, String, Boolean, Object)

Adds an operation to create a new primary key. 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_CAPS_protmethodAddPrimaryKey(String, String[], String, Boolean, Object)

Adds an operation to create a new primary key based on multiple columns. 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.


DbMigration.AddPrimaryKey Method (String, String, String, Boolean, Object)

Adds an operation to create a new primary key. 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.

[SuppressMessageAttribute("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
protected internal void AddPrimaryKey(
	string table,
	string column,
	string name = null,
	bool clustered = true,
	object anonymousArguments = null
)

Parameters

table
Type: System.String

The table that contains the primary key column. Schema name is optional, if no schema is specified then dbo is assumed.

column
Type: System.String

The primary key column.

name
Type: System.String

The name of the primary key in the database. If no value is supplied a unique name will be generated.

clustered
Type: System.Boolean

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

anonymousArguments
Type: System.Object

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


DbMigration.AddPrimaryKey Method (String, String[], String, Boolean, Object)

Adds an operation to create a new primary key based on multiple columns. 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.

[SuppressMessageAttribute("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
protected internal void AddPrimaryKey(
	string table,
	string[] columns,
	string name = null,
	bool clustered = true,
	object anonymousArguments = null
)

Parameters

table
Type: System.String

The table that contains the primary key columns. Schema name is optional, if no schema is specified then dbo is assumed.

columns
Type: System.String[]

The primary key columns.

name
Type: System.String

The name of the primary key in the database. If no value is supplied a unique name will be generated.

clustered
Type: System.Boolean

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

anonymousArguments
Type: System.Object

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