Class AddForeignKeyOperation
- Namespace
- Microsoft.EntityFrameworkCore.Migrations.Operations
- Assembly
- Microsoft.EntityFrameworkCore.Relational.dll
A MigrationOperation to add a new foreign key.
public class AddForeignKeyOperation : MigrationOperation, ITableMigrationOperation
- Inheritance
-
AddForeignKeyOperation
- Implements
- Inherited Members
Remarks
See Database migrations for more information and examples.
Constructors
AddForeignKeyOperation()
public AddForeignKeyOperation()
Properties
Columns
The ordered-list of column names for the columns that make up the foreign key.
public virtual string[] Columns { get; set; }
Property Value
- string[]
Name
The name of the foreign key constraint.
public virtual string Name { get; set; }
Property Value
OnDelete
The ReferentialAction to use for deletes.
public virtual ReferentialAction OnDelete { get; set; }
Property Value
OnUpdate
The ReferentialAction to use for updates.
public virtual ReferentialAction OnUpdate { get; set; }
Property Value
PrincipalColumns
The ordered-list of column names for the columns to which the columns that make up this foreign key are constrained, or null to constrain to the primary key columns.
public virtual string[]? PrincipalColumns { get; set; }
Property Value
- string[]
PrincipalSchema
The schema that contains the table to which this foreign key is constrained, or null if the default schema should be used.
public virtual string? PrincipalSchema { get; set; }
Property Value
PrincipalTable
The table to which the foreign key is constrained.
public virtual string PrincipalTable { get; set; }
Property Value
Schema
The schema that contains the table, or null if the default schema should be used.
public virtual string? Schema { get; set; }
Property Value
Table
The table to which the foreign key should be added.
public virtual string Table { get; set; }
Property Value
Methods
CreateFrom(IForeignKeyConstraint)
Creates a new AddForeignKeyOperation from the specified foreign key.
public static AddForeignKeyOperation CreateFrom(IForeignKeyConstraint foreignKey)
Parameters
foreignKey
IForeignKeyConstraintThe foreign key.
Returns
- AddForeignKeyOperation
The operation.