Entity Framework Multiple Column as Primary Key by Fluent Api

Use anonymous type object instead of 2 separated statements:

HasKey(pc => new { pc.ProductId, pc.CategoryId });

From Microsoft Docs: EntityTypeConfiguration.HasKey Method

If the primary key is made up of multiple properties then specify an anonymous type including the properties. For example, in C# t => new { t.Id1, t.Id2 } and in Visual Basic .Net Function(t) New With { t.Id1, t.Id2 }.