DbMigration.AddPrimaryKey Method (String, String, String, Boolean, Object)
[This page is specific to the Entity Framework version 6. The latest version is available as the 'Entity Framework' NuGet package. For more information about Entity Framework, see msdn.com/data/ef.]
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.
Namespace: System.Data.Entity.Migrations
Assembly: EntityFramework (in EntityFramework.dll)
Syntax
'Declaration
<SuppressMessageAttribute("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")> _
Protected Friend Sub AddPrimaryKey ( _
table As String, _
column As String, _
name As String, _
clustered As Boolean, _
anonymousArguments As Object _
)
'Usage
Dim table As String
Dim column As String
Dim name As String
Dim clustered As Boolean
Dim anonymousArguments As Object
Me.AddPrimaryKey(table, column, name, _
clustered, anonymousArguments)
[SuppressMessageAttribute("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
protected internal void AddPrimaryKey(
string table,
string column,
string name,
bool clustered,
Object anonymousArguments
)
[SuppressMessageAttribute(L"Microsoft.Design", L"CA1026:DefaultParametersShouldNotBeUsed")]
protected public:
void AddPrimaryKey(
String^ table,
String^ column,
String^ name,
bool clustered,
Object^ anonymousArguments
)
[<SuppressMessageAttribute("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")>]
member AddPrimaryKey :
table:string *
column:string *
name:string *
clustered:bool *
anonymousArguments:Object -> unit
function AddPrimaryKey(
table : String,
column : String,
name : String,
clustered : boolean,
anonymousArguments : Object
)
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" }'.