语言

ReferenceCollectionBuilder<TPrincipalEntity,TDependentEntity> 类

定义

提供用于配置一对多关系的简单 API。

public class ReferenceCollectionBuilder<TPrincipalEntity,TDependentEntity> : Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceCollectionBuilder where TPrincipalEntity : class where TDependentEntity : class
[System.Runtime.CompilerServices.Nullable(0)]
public class ReferenceCollectionBuilder<TPrincipalEntity,TDependentEntity> : Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceCollectionBuilder where TPrincipalEntity : class where TDependentEntity : class
type ReferenceCollectionBuilder<'PrincipalEntity, 'DependentEntity (requires 'PrincipalEntity : null and 'DependentEntity : null)> = class
    inherit ReferenceCollectionBuilder
[<System.Runtime.CompilerServices.Nullable(0)>]
type ReferenceCollectionBuilder<'PrincipalEntity, 'DependentEntity (requires 'PrincipalEntity : null and 'DependentEntity : null)> = class
    inherit ReferenceCollectionBuilder
Public Class ReferenceCollectionBuilder(Of TPrincipalEntity, TDependentEntity)
Inherits ReferenceCollectionBuilder

类型参数

TPrincipalEntity

此关系中的主体实体类型。

TDependentEntity

此关系中的依赖实体类型。

继承
ReferenceCollectionBuilder<TPrincipalEntity,TDependentEntity>
继承
ReferenceCollectionBuilder<TPrincipalEntity,TDependentEntity>
继承
ReferenceCollectionBuilder<TPrincipalEntity,TDependentEntity>
特性

注解

使用 ModelBuilder API 时,此类的实例会从方法返回,并且不会在应用程序代码中直接构造此类实例。

有关详细信息和示例,请参阅 建模实体类型和关系 。

构造函数

名称 说明
ReferenceCollectionBuilder<TPrincipalEntity,TDependentEntity>(EntityType, EntityType, InternalRelationshipBuilder)

此 API 支持Entity Framework Core基础结构,不打算直接从代码使用。 此 API 可能会在将来的版本中更改或删除。

ReferenceCollectionBuilder<TPrincipalEntity,TDependentEntity>(IMutableEntityType, IMutableEntityType, IMutableForeignKey)

这是一个内部 API,支持Entity Framework Core基础结构,不受与公共 API 相同的兼容性标准的约束。 可以在任何版本中更改或删除它,而不通知。 只需在代码中直接使用它,并非常谨慎地知道这样做可能会导致应用程序在更新到新的Entity Framework Core版本时失败。

ReferenceCollectionBuilder<TPrincipalEntity,TDependentEntity>(InternalForeignKeyBuilder, ReferenceCollectionBuilder, Boolean, Boolean, Boolean)

这是一个内部 API,支持Entity Framework Core基础结构,不受与公共 API 相同的兼容性标准的约束。 可以在任何版本中更改或删除它,而不通知。 只需在代码中直接使用它,并非常谨慎地知道这样做可能会导致应用程序在更新到新的Entity Framework Core版本时失败。

ReferenceCollectionBuilder<TPrincipalEntity,TDependentEntity>(InternalRelationshipBuilder, ReferenceCollectionBuilder, Boolean, Boolean, Boolean)

这是一个内部 API,支持Entity Framework Core基础结构,不受与公共 API 相同的兼容性标准的约束。 可以在任何版本中更改或删除它,而不通知。 只需在代码中直接使用它,并非常谨慎地知道这样做可能会导致应用程序在更新到新的Entity Framework Core版本时失败。

ReferenceCollectionBuilder<TPrincipalEntity,TDependentEntity>(InternalRelationshipBuilder)

此 API 支持Entity Framework Core基础结构,不打算直接从代码使用。 此 API 可能会在将来的版本中更改或删除。

属性

名称 说明
Builder

此 API 支持Entity Framework Core基础结构,不打算直接从代码使用。 此 API 可能会在将来的版本中更改或删除。

(继承自 ReferenceCollectionBuilder)
DependentEntityType

这是一个内部 API,支持Entity Framework Core基础结构,不受与公共 API 相同的兼容性标准的约束。 可以在任何版本中更改或删除它,而不通知。 只需在代码中直接使用它,并非常谨慎地知道这样做可能会导致应用程序在更新到新的Entity Framework Core版本时失败。

(继承自 RelationshipBuilderBase)
DependentEntityType

获取用于配置此关系的依赖实体类型。

(继承自 ReferenceCollectionBuilderBase)
Metadata

表示此关系的外键。

(继承自 ReferenceCollectionBuilder)
PrincipalEntityType

这是一个内部 API,支持Entity Framework Core基础结构,不受与公共 API 相同的兼容性标准的约束。 可以在任何版本中更改或删除它,而不通知。 只需在代码中直接使用它,并非常谨慎地知道这样做可能会导致应用程序在更新到新的Entity Framework Core版本时失败。

(继承自 RelationshipBuilderBase)
PrincipalEntityType

获取用于配置此关系的主体实体类型。

(继承自 ReferenceCollectionBuilderBase)

方法

名称 说明
HasAnnotation(String, Object)

添加或更新关系上的批注。 如果具有指定键的 annotation 批注已存在,则会更新其值。

HasForeignKey(Expression<Func<TDependentEntity,Object>>)

将属性配置为用作此关系的外键。

HasForeignKey(String[])

将属性配置为用作此关系的外键。

HasForeignKeyBuilder(IReadOnlyList<MemberInfo>)

这是一个内部 API,支持Entity Framework Core基础结构,不受与公共 API 相同的兼容性标准的约束。 可以在任何版本中更改或删除它,而不通知。 只需在代码中直接使用它,并非常谨慎地知道这样做可能会导致应用程序在更新到新的Entity Framework Core版本时失败。

(继承自 ReferenceCollectionBuilder)
HasForeignKeyBuilder(IReadOnlyList<PropertyInfo>)

此 API 支持Entity Framework Core基础结构,不打算直接从代码使用。 此 API 可能会在将来的版本中更改或删除。

(继承自 ReferenceCollectionBuilder)
HasForeignKeyBuilder(IReadOnlyList<String>)

这是一个内部 API,支持Entity Framework Core基础结构,不受与公共 API 相同的兼容性标准的约束。 可以在任何版本中更改或删除它,而不通知。 只需在代码中直接使用它,并非常谨慎地知道这样做可能会导致应用程序在更新到新的Entity Framework Core版本时失败。

(继承自 ReferenceCollectionBuilder)
HasPrincipalKey(Expression<Func<TPrincipalEntity,Object>>)

配置此关系所面向的唯一属性。 通常,如果想要将主键以外的属性用作主体属性(s),则仅调用此方法。 如果指定的属性(s)不是唯一约束(或主键),则将引入新的唯一约束。

HasPrincipalKey(String[])

配置此关系所面向的唯一属性。 通常,如果想要将主键以外的属性用作主体属性(s),则仅调用此方法。 如果指定的属性(s)不是唯一约束(或主键),则将引入新的唯一约束。

HasPrincipalKeyBuilder(IReadOnlyList<MemberInfo>)

这是一个内部 API,支持Entity Framework Core基础结构,不受与公共 API 相同的兼容性标准的约束。 可以在任何版本中更改或删除它,而不通知。 只需在代码中直接使用它,并非常谨慎地知道这样做可能会导致应用程序在更新到新的Entity Framework Core版本时失败。

(继承自 ReferenceCollectionBuilder)
HasPrincipalKeyBuilder(IReadOnlyList<PropertyInfo>)

此 API 支持Entity Framework Core基础结构,不打算直接从代码使用。 此 API 可能会在将来的版本中更改或删除。

(继承自 ReferenceCollectionBuilder)
HasPrincipalKeyBuilder(IReadOnlyList<String>)

这是一个内部 API,支持Entity Framework Core基础结构,不受与公共 API 相同的兼容性标准的约束。 可以在任何版本中更改或删除它,而不通知。 只需在代码中直接使用它,并非常谨慎地知道这样做可能会导致应用程序在更新到新的Entity Framework Core版本时失败。

(继承自 ReferenceCollectionBuilder)
IsConstrained(Boolean)

配置关系是否受约束。 创建数据库外键约束时 false,查询将关系视为可选(主体不假定存在),即使外键属性不可为 null 也是如此。 这不会影响更改跟踪。 请参阅 IsConstrained。

IsRequired(Boolean)

配置这是否为必需关系(即是否可以分配 null外键属性)。

OnDelete(DeleteBehavior)

配置在删除主体或断开关系时应用于关系中的从属实体的操作。

OnDelete(DeleteBehavior)

配置删除主体或断开关系时,如何对关系中的依赖实体应用删除操作。

显式接口实现

名称 说明
IInfrastructure<IConventionForeignKeyBuilder>.Instance

获取用于配置此关系的内部生成器。

(继承自 RelationshipBuilderBase)
IInfrastructure<IMutableModel>.Instance

此关系所属的模型。

(继承自 ReferenceCollectionBuilder)
IInfrastructure<InternalRelationshipBuilder>.Instance

获取用于配置此关系的内部生成器。

(继承自 ReferenceCollectionBuilder)

扩展方法

名称 说明
ExcludeForeignKeyFromMigrations(ReferenceCollectionBuilder, Boolean)

配置在面向关系数据库时是否从迁移中排除外键约束。

ExcludeForeignKeyFromMigrations<TEntity,TRelatedEntity>(ReferenceCollectionBuilder<TEntity,TRelatedEntity>, Boolean)

配置在面向关系数据库时是否从迁移中排除外键约束。

ForSqliteHasConstraintName(ReferenceCollectionBuilder, String)

针对 SQLite 配置此关系的外键约束名称。

ForSqliteHasConstraintName<TEntity,TReferencedEntity>(ReferenceCollectionBuilder<TEntity,TReferencedEntity>, String)

针对 SQLite 配置此关系的外键约束名称。

ForSqlServerHasConstraintName(ReferenceCollectionBuilder, String)

针对SQL Server时配置此关系的外键约束名称。

ForSqlServerHasConstraintName<TEntity,TRelatedEntity>(ReferenceCollectionBuilder<TEntity,TRelatedEntity>, String)

针对SQL Server时配置此关系的外键约束名称。

GetInfrastructure<T>(IInfrastructure<T>)

从正在使用的隐藏 IInfrastructure<T>属性中获取值。

此方法通常由数据库提供程序(和其他扩展)使用。 它通常不用于应用程序代码。

HasConstraintName(ReferenceCollectionBuilder, String)

针对关系数据库时配置此关系的外键约束名称。

HasConstraintName(ReferenceCollectionBuilder, String)

针对关系数据库时配置此关系的外键约束名称。

HasConstraintName<TEntity,TRelatedEntity>(ReferenceCollectionBuilder<TEntity,TRelatedEntity>, String)

针对关系数据库时配置此关系的外键约束名称。

HasConstraintName<TEntity,TRelatedEntity>(ReferenceCollectionBuilder<TEntity,TRelatedEntity>, String)

针对关系数据库时配置此关系的外键约束名称。

适用于