Entity Framework Multiple Column als Primärschlüssel von Fluent Api

Dies sind meine vereinfachten Domainklassen.

public class ProductCategory
{
    public int ProductId { get; set; }
    public int CategoryId { get; set; }

    public virtual Product Product { get; set; }
    public virtual Category Category { get; set; }
}

public class Product
{
    public int Id { get; set; }
    public string Name { get; set; }
} 

public class Category
{
    public int Id { get; set; }
    public string Name { get; set; }
    public int? ParentCategoryId { get; set;} 
} 

Dies ist meine Mapping-Klasse. Aber es funktioniert nicht.

public class ProductCategoryMap : EntityTypeConfiguration<ProductCategory>
{
    public ProductCategoryMap()
    {
        ToTable("ProductCategory");
        HasKey(pc => pc.ProductId);
        HasKey(pc => pc.CategoryId);
    }
}

Wie soll ich diese Klassen zuordnen, damit ein Produkt in mehreren Kategorien angezeigt wird?

Antworten auf die Frage(2)

Ihre Antwort auf die Frage