DbMigration.AddForeignKey Method
Adds an operation to create a new foreign key constraint.
Assembly: EntityFramework (in EntityFramework.dll)
Name | Description | |
---|---|---|
![]() | 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. |
DbMigration.AddForeignKey Method (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.
[SuppressMessageAttribute("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 )
Parameters
- dependentTable
-
Type:
System.String
The table that contains the foreign key column. Schema name is optional, if no schema is specified then dbo is assumed.
- dependentColumn
-
Type:
System.String
The foreign key column.
- principalTable
-
Type:
System.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
-
Type:
System.String
The column this foreign key references. If no value is supplied the primary key of the principal table will be referenced.
- cascadeDelete
-
Type:
System.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
-
Type:
System.String
The name of the foreign key constraint in the database. If no value is supplied a unique name will be generated.
- 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.AddForeignKey Method (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.
[SuppressMessageAttribute("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 )
Parameters
- dependentTable
-
Type:
System.String
The table that contains the foreign key columns. Schema name is optional, if no schema is specified then dbo is assumed.
- dependentColumns
-
Type:
System.String[]
The foreign key columns.
- principalTable
-
Type:
System.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
-
Type:
System.String[]
The columns this foreign key references. If no value is supplied the primary key of the principal table will be referenced.
- cascadeDelete
-
Type:
System.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
-
Type:
System.String
The name of the foreign key constraint in the database. If no value is supplied a unique name will be generated.
- 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" }'.