我正在研究 Entity Framework 4.1 并为外键使用数据注释。我想知道我们如何定义产品和类别之间的一对多关系。我想映射类别。categoryId 和 product.cid
public class Category
{
public string CategoryId { get; set; }
public string Name { get; set; }
public virtual ICollection<Product> Products { get; set; }
}
public class Product
{
public int ProductId { get; set; }
public string Name { get; set; }
public string CId { get; set; }
public virtual Category Category { get; set; }
}
请建议