我目前有一堂课:
[Table("TitleCategoryMovie", Schema = "dbo")]
public class TitleCategoryMovie
{
[Key]
public int Id { get; set; }
public string CreatedBy { get; set; }
public DateTime CreateDatetime { get; set; }
public string UpdatedBy { get; set; }
public DateTime UpdateDatetime { get; set; }
[ForeignKey("Id")]
public virtual Title Title { get; set; }
}
有一个表叫Title
. 并且每个TitleCategoryMovie
都有一个对应的Title
,虽然不是每个Title
都有一个TitleCategoryMovie
。Title列Id
与 TitleCategoryMovie 相同。但是当我将两个实体类添加到我的 DbContext 时,它给了我一个错误:
Multiplicity is not valid in Role 'TitleCategoryMovieStandalone_Title_Source' in relationship 'TitleCategoryMovieStandalone_Title'. Because the Dependent Role refers to the key properties, the upper bound of the multiplicity of the Dependent Role must be �1�.
我已经将我的列定义Id
为主TitleCategoryMovie
键和外键Title
,所以我不知道为什么它会给我这个错误。怎么了?