The method HasKey
has a signature that has as parameter a delegate that receives its entity as parameter and returns a object
. This means that the content you return (in theory can be anything because it is a object
) will be your primary key.
An example (example only, do not use this implementation) what you could do to see that it is accepted is to create a method that meets the subscription and perform the test:
public object Teste(Entidade a)
{
return 10;
}
builder.HasKey(a => Teste(a));
So the method has the purpose of defining which will be the primary key of your entity, for this reason we do not define a "search criteria" as you commented above, because it only needs a return that the Entity Framework will use as the primary key for this entity.