Entity Framework Multiple Column als Primärschlüssel von Fluent Api
Das sind meine vereinfachte domain-Klassen.
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 mein 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 anzeigen diese Klassen anbieten, so dass ein Produkt gesehen werden kann in mehreren Kategorien ?
InformationsquelleAutor der Frage Ryu Kaplan | 2013-03-16
Du musst angemeldet sein, um einen Kommentar abzugeben.
Anonyme Typ-Objekt, das anstelle von 2 getrennten Aussagen:
Aus der MSDN: EntityTypeConfiguration.HasKey-Methode
InformationsquelleAutor der Antwort MarcinJuraszek