MigrationBuilder.AddForeignKey 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
重载
AddForeignKey(String, String, String, String, String, String, String, ReferentialAction, ReferentialAction)
- Source:
- MigrationBuilder.cs
- Source:
- MigrationBuilder.cs
- Source:
- MigrationBuilder.cs
- Source:
- MigrationBuilder.cs
- Source:
- MigrationBuilder.cs
- Source:
- MigrationBuilder.cs
- Source:
- MigrationBuilder.cs
- Source:
- MigrationBuilder.cs
- Source:
- MigrationBuilder.cs
生成 以 AddForeignKeyOperation 向表添加新的外键。
public virtual Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder<Microsoft.EntityFrameworkCore.Migrations.Operations.AddForeignKeyOperation> AddForeignKey (string name, string table, string column, string principalTable, string schema = default, string principalSchema = default, string principalColumn = default, Microsoft.EntityFrameworkCore.Migrations.ReferentialAction onUpdate = Microsoft.EntityFrameworkCore.Migrations.ReferentialAction.NoAction, Microsoft.EntityFrameworkCore.Migrations.ReferentialAction onDelete = Microsoft.EntityFrameworkCore.Migrations.ReferentialAction.NoAction);
public virtual Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder<Microsoft.EntityFrameworkCore.Migrations.Operations.AddForeignKeyOperation> AddForeignKey (string name, string table, string column, string principalTable, string? schema = default, string? principalSchema = default, string? principalColumn = default, Microsoft.EntityFrameworkCore.Migrations.ReferentialAction onUpdate = Microsoft.EntityFrameworkCore.Migrations.ReferentialAction.NoAction, Microsoft.EntityFrameworkCore.Migrations.ReferentialAction onDelete = Microsoft.EntityFrameworkCore.Migrations.ReferentialAction.NoAction);
abstract member AddForeignKey : string * string * string * string * string * string * string * Microsoft.EntityFrameworkCore.Migrations.ReferentialAction * Microsoft.EntityFrameworkCore.Migrations.ReferentialAction -> Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder<Microsoft.EntityFrameworkCore.Migrations.Operations.AddForeignKeyOperation>
override this.AddForeignKey : string * string * string * string * string * string * string * Microsoft.EntityFrameworkCore.Migrations.ReferentialAction * Microsoft.EntityFrameworkCore.Migrations.ReferentialAction -> Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder<Microsoft.EntityFrameworkCore.Migrations.Operations.AddForeignKeyOperation>
Public Overridable Function AddForeignKey (name As String, table As String, column As String, principalTable As String, Optional schema As String = Nothing, Optional principalSchema As String = Nothing, Optional principalColumn As String = Nothing, Optional onUpdate As ReferentialAction = Microsoft.EntityFrameworkCore.Migrations.ReferentialAction.NoAction, Optional onDelete As ReferentialAction = Microsoft.EntityFrameworkCore.Migrations.ReferentialAction.NoAction) As OperationBuilder(Of AddForeignKeyOperation)
参数
- name
- String
外键约束名称。
- table
- String
包含外键的表。
- column
- String
受约束的列。
- principalTable
- String
外键受约束的表。
- schema
- String
包含表的架构,或者 null
是否应使用默认架构。
- principalSchema
- String
包含主体表的架构,或者 null
是否应使用默认架构。
- principalColumn
- String
外键列受约束的列,或 null
约束为主键列。
- onUpdate
- ReferentialAction
要对更新执行的操作。
- onDelete
- ReferentialAction
要对删除执行的操作。
返回
一个生成器,允许将批注添加到操作中。
注解
有关详细信息和示例 ,请参阅数据库迁移 。
适用于
AddForeignKey(String, String, String[], String, String, String, String[], ReferentialAction, ReferentialAction)
- Source:
- MigrationBuilder.cs
- Source:
- MigrationBuilder.cs
- Source:
- MigrationBuilder.cs
- Source:
- MigrationBuilder.cs
- Source:
- MigrationBuilder.cs
- Source:
- MigrationBuilder.cs
- Source:
- MigrationBuilder.cs
- Source:
- MigrationBuilder.cs
- Source:
- MigrationBuilder.cs
生成 以 AddForeignKeyOperation 向表添加新的复合 (多列) 外键。
public virtual Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder<Microsoft.EntityFrameworkCore.Migrations.Operations.AddForeignKeyOperation> AddForeignKey (string name, string table, string[] columns, string principalTable, string schema = default, string principalSchema = default, string[] principalColumns = default, Microsoft.EntityFrameworkCore.Migrations.ReferentialAction onUpdate = Microsoft.EntityFrameworkCore.Migrations.ReferentialAction.NoAction, Microsoft.EntityFrameworkCore.Migrations.ReferentialAction onDelete = Microsoft.EntityFrameworkCore.Migrations.ReferentialAction.NoAction);
public virtual Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder<Microsoft.EntityFrameworkCore.Migrations.Operations.AddForeignKeyOperation> AddForeignKey (string name, string table, string[] columns, string principalTable, string? schema = default, string? principalSchema = default, string[]? principalColumns = default, Microsoft.EntityFrameworkCore.Migrations.ReferentialAction onUpdate = Microsoft.EntityFrameworkCore.Migrations.ReferentialAction.NoAction, Microsoft.EntityFrameworkCore.Migrations.ReferentialAction onDelete = Microsoft.EntityFrameworkCore.Migrations.ReferentialAction.NoAction);
abstract member AddForeignKey : string * string * string[] * string * string * string * string[] * Microsoft.EntityFrameworkCore.Migrations.ReferentialAction * Microsoft.EntityFrameworkCore.Migrations.ReferentialAction -> Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder<Microsoft.EntityFrameworkCore.Migrations.Operations.AddForeignKeyOperation>
override this.AddForeignKey : string * string * string[] * string * string * string * string[] * Microsoft.EntityFrameworkCore.Migrations.ReferentialAction * Microsoft.EntityFrameworkCore.Migrations.ReferentialAction -> Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder<Microsoft.EntityFrameworkCore.Migrations.Operations.AddForeignKeyOperation>
Public Overridable Function AddForeignKey (name As String, table As String, columns As String(), principalTable As String, Optional schema As String = Nothing, Optional principalSchema As String = Nothing, Optional principalColumns As String() = Nothing, Optional onUpdate As ReferentialAction = Microsoft.EntityFrameworkCore.Migrations.ReferentialAction.NoAction, Optional onDelete As ReferentialAction = Microsoft.EntityFrameworkCore.Migrations.ReferentialAction.NoAction) As OperationBuilder(Of AddForeignKeyOperation)
参数
- name
- String
外键约束名称。
- table
- String
包含外键的表。
- columns
- String[]
受约束的列的有序列表。
- principalTable
- String
外键受约束的表。
- schema
- String
包含表的架构,或者 null
是否应使用默认架构。
- principalSchema
- String
包含主体表的架构,或者 null
是否应使用默认架构。
- principalColumns
- String[]
外键列受约束的列,或 null
约束为主键列。
- onUpdate
- ReferentialAction
要对更新执行的操作。
- onDelete
- ReferentialAction
要对删除执行的操作。
返回
一个生成器,允许将批注添加到操作中。
注解
有关详细信息和示例 ,请参阅数据库迁移 。