Table of Contents

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

string

OnDelete

The ReferentialAction to use for deletes.

public virtual ReferentialAction OnDelete { get; set; }

Property Value

ReferentialAction

OnUpdate

The ReferentialAction to use for updates.

public virtual ReferentialAction OnUpdate { get; set; }

Property Value

ReferentialAction

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

string

PrincipalTable

The table to which the foreign key is constrained.

public virtual string PrincipalTable { get; set; }

Property Value

string

Schema

The schema that contains the table, or null if the default schema should be used.

public virtual string? Schema { get; set; }

Property Value

string

Table

The table to which the foreign key should be added.

public virtual string Table { get; set; }

Property Value

string

Methods

CreateFrom(IForeignKeyConstraint)

Creates a new AddForeignKeyOperation from the specified foreign key.

public static AddForeignKeyOperation CreateFrom(IForeignKeyConstraint foreignKey)

Parameters

foreignKey IForeignKeyConstraint

The foreign key.

Returns

AddForeignKeyOperation

The operation.