OwnedNavigationBuilder<TOwnerEntity,TDependentEntity>.HasKey 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
重载
| 名称 | 说明 |
|---|---|
| HasKey(String[]) |
设置构成此自有实体类型的主键的属性。 |
| HasKey(Expression<Func<TDependentEntity,Object>>) |
设置构成此自有实体类型的主键的属性。 |
HasKey(String[])
- Source:
- OwnedNavigationBuilder`.cs
- Source:
- OwnedNavigationBuilder`.cs
- Source:
- OwnedNavigationBuilder`.cs
- Source:
- OwnedNavigationBuilder`.cs
- Source:
- OwnedNavigationBuilder`.cs
- Source:
- OwnedNavigationBuilder`.cs
- Source:
- OwnedNavigationBuilder`.cs
设置构成此自有实体类型的主键的属性。
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.KeyBuilder<TDependentEntity> HasKey(params string[] propertyNames);
override this.HasKey : string[] -> Microsoft.EntityFrameworkCore.Metadata.Builders.KeyBuilder<'DependentEntity (requires 'DependentEntity : null)>
Public Overridable Function HasKey (ParamArray propertyNames As String()) As KeyBuilder(Of TDependentEntity)
参数
- propertyNames
- String[]
构成主键的属性的名称。
返回
KeyBuilder<TDependentEntity>
可用于配置主键的对象。
适用于
HasKey(Expression<Func<TDependentEntity,Object>>)
- Source:
- OwnedNavigationBuilder`.cs
- Source:
- OwnedNavigationBuilder`.cs
- Source:
- OwnedNavigationBuilder`.cs
- Source:
- OwnedNavigationBuilder`.cs
- Source:
- OwnedNavigationBuilder`.cs
- Source:
- OwnedNavigationBuilder`.cs
- Source:
- OwnedNavigationBuilder`.cs
- Source:
- OwnedNavigationBuilder`.cs
- Source:
- OwnedNavigationBuilder`.cs
设置构成此自有实体类型的主键的属性。
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.KeyBuilder<TDependentEntity> HasKey(System.Linq.Expressions.Expression<Func<TDependentEntity,object?>> keyExpression);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.KeyBuilder HasKey(System.Linq.Expressions.Expression<Func<TDependentEntity,object>> keyExpression);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.KeyBuilder<TDependentEntity> HasKey(System.Linq.Expressions.Expression<Func<TDependentEntity,object>> keyExpression);
override this.HasKey : System.Linq.Expressions.Expression<Func<'DependentEntity, obj>> -> Microsoft.EntityFrameworkCore.Metadata.Builders.KeyBuilder<'DependentEntity (requires 'DependentEntity : null)>
override this.HasKey : System.Linq.Expressions.Expression<Func<'DependentEntity, obj>> -> Microsoft.EntityFrameworkCore.Metadata.Builders.KeyBuilder
Public Overridable Function HasKey (keyExpression As Expression(Of Func(Of TDependentEntity, Object))) As KeyBuilder(Of TDependentEntity)
Public Overridable Function HasKey (keyExpression As Expression(Of Func(Of TDependentEntity, Object))) As KeyBuilder
参数
- keyExpression
- Expression<Func<TDependentEntity,Object>>
一个 lambda 表达式,表示主键属性(s) (blog => blog.Url)。
如果主键由多个属性组成,则指定一个匿名类型,包括属性(post => new { post.Title, post.BlogId })。
返回
KeyBuilder<TDependentEntity>
可用于配置主键的对象。