【发布时间】:2011-03-17 13:52:28
【问题描述】:
在尝试使用 Code First 创建一对一关系时,我目前遇到以下错误: System.Data.Edm.EdmAssociationEnd::多重性在关系“C001_Holding_Teste_C001_Holding”中的角色“C001_Holding_Teste_C001_Holding_Source”中无效。因为 Dependent Role 指的是关键属性,所以 Dependent Role 的多重性的上限必须为 1。 我的实体定义如下:
[Table("C001_Holding", Schema = "Cad")]
public partial class C001_Holding
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int C001_Id { get; set; }
[MaxLength(16)]
public string C001_Codigo { get; set; }
[MaxLength(100)]
public string C001_Descricao { get; set; }
}
public class C001_Holding_Test
{
[Key]
public int C001_Id { get; set; }
[MaxLength(100)]
public string C001_TestInfo { get; set; }
[ForeignKey("C001_Id")]
public virtual C001_Holding C001_Holding { get; set; }
}
我不想使用 Fluent 来创建这些关系,有人知道为什么会这样吗?
Tks.
【问题讨论】:
标签: entity-framework ef-code-first