ReferenceReferenceBuilder<TEntity,TRelatedEntity>.HasPrincipalKey 方法

定义

重载

HasPrincipalKey(String, String[])

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

HasPrincipalKey(Type, String[])

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

HasPrincipalKey<TPrincipalEntity>(Expression<Func<TPrincipalEntity,Object>>)

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

HasPrincipalKey<TPrincipalEntity>(String[])

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

HasPrincipalKey(String, String[])

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

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceReferenceBuilder<TEntity,TRelatedEntity> HasPrincipalKey (string principalEntityTypeName, params string[] keyPropertyNames);
override this.HasPrincipalKey : string * string[] -> Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceReferenceBuilder<'Entity, 'RelatedEntity (requires 'Entity : null and 'RelatedEntity : null)>
Public Overridable Function HasPrincipalKey (principalEntityTypeName As String, ParamArray keyPropertyNames As String()) As ReferenceReferenceBuilder(Of TEntity, TRelatedEntity)

参数

principalEntityTypeName
String

作为此关系中主体的实体类型的名称 () 引用键属性的类型。

keyPropertyNames
String[]

引用键属性的名称 () () 。

返回

同一个生成器实例,以便可以链接多个配置调用。

注解

如果指定了多个主体键属性,则主体键属性的顺序应与在主体实体类型上配置主键或唯一约束属性的顺序匹配。

适用于

HasPrincipalKey(Type, String[])

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

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceReferenceBuilder<TEntity,TRelatedEntity> HasPrincipalKey (Type principalEntityType, params string[] keyPropertyNames);
override this.HasPrincipalKey : Type * string[] -> Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceReferenceBuilder<'Entity, 'RelatedEntity (requires 'Entity : null and 'RelatedEntity : null)>
Public Overridable Function HasPrincipalKey (principalEntityType As Type, ParamArray keyPropertyNames As String()) As ReferenceReferenceBuilder(Of TEntity, TRelatedEntity)

参数

principalEntityType
Type

作为此关系中主体的实体类型 () 引用键属性的类型。

keyPropertyNames
String[]

引用键属性的名称 () () 。

返回

同一个生成器实例,以便可以链接多个配置调用。

注解

如果指定了多个主体键属性,则主体键属性的顺序应与在主体实体类型上配置主键或唯一约束属性的顺序匹配。

适用于

HasPrincipalKey<TPrincipalEntity>(Expression<Func<TPrincipalEntity,Object>>)

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

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceReferenceBuilder<TEntity,TRelatedEntity> HasPrincipalKey<TPrincipalEntity> (System.Linq.Expressions.Expression<Func<TPrincipalEntity,object>> keyExpression);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceReferenceBuilder<TEntity,TRelatedEntity> HasPrincipalKey<TPrincipalEntity> (System.Linq.Expressions.Expression<Func<TPrincipalEntity,object>> keyExpression) where TPrincipalEntity : class;
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceReferenceBuilder<TEntity,TRelatedEntity> HasPrincipalKey<TPrincipalEntity> (System.Linq.Expressions.Expression<Func<TPrincipalEntity,object?>> keyExpression) where TPrincipalEntity : class;
override this.HasPrincipalKey : System.Linq.Expressions.Expression<Func<'PrincipalEntity, obj>> -> Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceReferenceBuilder<'Entity, 'RelatedEntity (requires 'Entity : null and 'RelatedEntity : null)>
override this.HasPrincipalKey : System.Linq.Expressions.Expression<Func<'PrincipalEntity, obj>> -> Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceReferenceBuilder<'Entity, 'RelatedEntity (requires 'Entity : null and 'RelatedEntity : null)> (requires 'PrincipalEntity : null)
Public Overridable Function HasPrincipalKey(Of TPrincipalEntity) (keyExpression As Expression(Of Func(Of TPrincipalEntity, Object))) As ReferenceReferenceBuilder(Of TEntity, TRelatedEntity)
Public Overridable Function HasPrincipalKey(Of TPrincipalEntity As Class) (keyExpression As Expression(Of Func(Of TPrincipalEntity, Object))) As ReferenceReferenceBuilder(Of TEntity, TRelatedEntity)

类型参数

TPrincipalEntity

作为此关系中的主体的实体类型。 也就是说,具有引用键属性的类型。

参数

keyExpression
Expression<Func<TPrincipalEntity,Object>>

一个 lambda 表达式,表示引用键属性 () (t => t.Id) 。

如果主体键由多个属性组成,则指定一个匿名类型,包括 (t => new { t.Id1, t.Id2 }) 的属性。 指定的顺序应与 中 HasForeignKey<TDependentEntity>(Expression<Func<TDependentEntity,Object>>)相应属性的顺序匹配。

返回

同一个生成器实例,以便可以链接多个配置调用。

注解

如果指定了多个主体键属性,则主体键属性的顺序应与在主体实体类型上配置主键或唯一约束属性的顺序匹配。

适用于

HasPrincipalKey<TPrincipalEntity>(String[])

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

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceReferenceBuilder<TEntity,TRelatedEntity> HasPrincipalKey<TPrincipalEntity> (params string[] keyPropertyNames) where TPrincipalEntity : class;
override this.HasPrincipalKey : string[] -> Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceReferenceBuilder<'Entity, 'RelatedEntity (requires 'Entity : null and 'RelatedEntity : null)> (requires 'PrincipalEntity : null)
Public Overridable Function HasPrincipalKey(Of TPrincipalEntity As Class) (ParamArray keyPropertyNames As String()) As ReferenceReferenceBuilder(Of TEntity, TRelatedEntity)

类型参数

TPrincipalEntity

作为此关系中主体的实体类型 () 引用键属性的类型。

参数

keyPropertyNames
String[]

引用键属性的名称 () () 。

返回

同一个生成器实例,以便可以链接多个配置调用。

适用于