On EF core ..
Composite keys can only be configured using the Fluent API –
conventions will never setup a composite key and you can not use Data
Annotations to configure one.
Here is the Fluent API version :
Note: This is just an example. Please adjust it according to your use case.
// (In the DbContext subclass)
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Attends>()
.HasKey(c => new { c.FarmerSS, c. HotelID });
}
You can read more about it here : composite key