【发布时间】:2013-12-08 08:20:29
【问题描述】:
我在 asp.net 应用程序网络表单中使用 codefirst EF。我要上课:
public class Product
{
[ScaffoldColumn(false)]
public int ProductID { get; set; }
public string ProductName { get; set; }
public virtual Picture Pic{ get; set; }
}
public class Picture
{
[ScaffoldColumn(false)]
[Key]
public int PictureID { get; set; }
public String Path { get; set; }
[ForeignKey("Product")]
public int? ProductID { get; set; }
public virtual Product Product { get; set; }
}
这些类之间的关系是一对一的。我设置了 ForeignKey 属性,但是当我运行 Update-database 时,我收到“多重性在角色中无效。因为从属角色属性不是关键属性,所以从属角色多重性的上限必须是 '*'。” 你能帮帮我吗?
【问题讨论】:
标签: asp.net entity-framework ef-code-first