0
我使用EF代碼第一次和我的數據庫模型有效看起來如下:EF錯誤:多重不在角色
public abstract class Job
{
public int Id { get; set; }
public JobResult Result { get; set; }
}
[Table("RegisterDomainJobs")]
public class RegisterDomainJob : Job
{
}
public abstract class JobResult
{
public int Id { get; set; }
[ForeignKey("Job")]
public int JobId { get; set; }
[Required]
public virtual Job Job { get; set; }
}
[Table("GenericJobResults")]
public class GenericJobResult : JobResult
{
}
然而,當我運行更新,數據庫命令我得到以下錯誤:
JobResult_Job_Source: : Multiplicity is not valid in Role 'JobResult_Job_Source' in relationship 'JobResult_Job'. Because the Dependent Role properties are not the key properties, the upper bound of the multiplicity of the Dependent Role must be '*'.
奇怪的是,這個錯誤只發生在我不斷:
[ForeignKey("Job")]
public int JobId { get; set; }
在我的模型中。
這個問題的原因是什麼?
啊我看 - 這非常合理。 非常感謝! – JensOlsen112 2014-11-01 19:17:50