Share via


DbMigration.AddForeignKey Method

Definition

Overloads

AddForeignKey(String, String, String, String, Boolean, String, Object)

Adds an operation to create a new foreign key constraint.

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.

AddForeignKey(String, String[], String, String[], Boolean, String, Object)

Adds an operation to create a new foreign key constraint.

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.

AddForeignKey(String, String, String, String, Boolean, String, Object)

Adds an operation to create a new foreign key constraint.

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.

protected internal void AddForeignKey (string dependentTable, string dependentColumn, string principalTable, string principalColumn = null, bool cascadeDelete = false, string name = null, object anonymousArguments = null);
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
protected internal void AddForeignKey (string dependentTable, string dependentColumn, string principalTable, string principalColumn = null, bool cascadeDelete = false, string name = null, object anonymousArguments = null);
member this.AddForeignKey : string * string * string * string * bool * string * obj -> unit
Protected Friend Sub AddForeignKey (dependentTable As String, dependentColumn As String, principalTable As String, Optional principalColumn As String = null, Optional cascadeDelete As Boolean = false, Optional name As String = null, Optional anonymousArguments As Object = null)

Parameters

dependentTable
String

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

dependentColumn
String

The foreign key column.

principalTable
String

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

principalColumn
String

The column this foreign key references. If no value is supplied the primary key of the principal table will be referenced.

cascadeDelete
Boolean

A value indicating if cascade delete should be configured for the foreign key relationship. If no value is supplied, cascade delete will be off.

name
String

The name of the foreign key constraint in the database. If no value is supplied a unique 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" }'.

Attributes

Applies to

AddForeignKey(String, String[], String, String[], Boolean, String, Object)

Adds an operation to create a new foreign key constraint.

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.

protected internal void AddForeignKey (string dependentTable, string[] dependentColumns, string principalTable, string[] principalColumns = null, bool cascadeDelete = false, string name = null, object anonymousArguments = null);
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
protected internal void AddForeignKey (string dependentTable, string[] dependentColumns, string principalTable, string[] principalColumns = null, bool cascadeDelete = false, string name = null, object anonymousArguments = null);
member this.AddForeignKey : string * string[] * string * string[] * bool * string * obj -> unit
Protected Friend Sub AddForeignKey (dependentTable As String, dependentColumns As String(), principalTable As String, Optional principalColumns As String() = null, Optional cascadeDelete As Boolean = false, Optional name As String = null, Optional anonymousArguments As Object = null)

Parameters

dependentTable
String

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

dependentColumns
String[]

The foreign key columns.

principalTable
String

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

principalColumns
String[]

The columns this foreign key references. If no value is supplied the primary key of the principal table will be referenced.

cascadeDelete
Boolean

A value indicating if cascade delete should be configured for the foreign key relationship. If no value is supplied, cascade delete will be off.

name
String

The name of the foreign key constraint in the database. If no value is supplied a unique 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" }'.

Attributes

Applies to