src/EntityFramework/ModelConfiguration/EntityTypeConfiguration.cs
/// <summary>
///     Configures the primary key property(s) for this entity type.
/// </summary>
/// <typeparam name="TKey"> The type of the key. </typeparam>
/// <param name="keyExpression"> A lambda expression representing the property to be used as the primary key. C#: t => t.Id VB.Net: Function(t) t.Id If the primary key is made up of multiple properties then specify an anonymous type including the properties. C#: t => new { t.Id1, t.Id2 } VB.Net: Function(t) New With { t.Id1, t.Id2 } </param>
/// <returns> The same EntityTypeConfiguration instance so that multiple calls can be chained. </returns>
Configures the primary key property(s) for this entity type.
Configures the primary key property ( s ) for this entity type .
[SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
        [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
        public EntityTypeConfiguration<TEntityType> HasKey<TKey>(Expression<Func<TEntityType, TKey>> keyExpression)
        {
            Check.NotNull(keyExpression, "keyExpression");
            _entityTypeConfiguration.Key(keyExpression.GetSimplePropertyAccessList().Select(p => p.Single()));
            return this;
        }
[ SuppressMessage ( " " , " " ) ] [ SuppressMessage ( " " , " " ) ] public EntityTypeConfiguration < TEntityType > HasKey < TKey > ( Expression < Func < TEntityType , TKey > > keyExpression ) { Check . NotNull ( keyExpression , " " ) ; _entityTypeConfiguration . Key ( keyExpression . GetSimplePropertyAccessList ( ) . Select ( p => p . Single ( ) ) ) ; return this ; }
Configures the primary key property(s) for this entity type.
Configures the primary key property ( s ) for this entity type .
The same EntityTypeConfiguration instance so that multiple calls can be chained.
The same EntityTypeConfiguration instance so that multiple calls can be chained .
keyExpression
Expression<Func<TEntityType, TKey>>
A lambda expression representing the property to be used as the primary key. C#: t => t.Id VB.Net: Function(t) t.Id If the primary key is made up of multiple properties then specify an anonymous type including the properties.
A lambda expression representing the property to be used as the primary key . C# : t = > t . Id VB . Net : Function ( t ) t . Id If the primary key is made up of multiple properties then specify an anonymous type including the properties .
typeparam
The type of the key.
The type of the key .