0
嘗試在EF中添加遷移時遇到問題。該錯誤是關係約束中的從屬角色和主角色中的屬性數量必須相同
RegisterCountLog_Register_Target_RegisterCountLog_Register_Source:在一個關係約束的從屬和主角色屬性的數目必須是相同的。
的類如下:
public class RegisterCountLog
{
[ForeignKey("CountLog")]
public long DeviceSerial { get; set; }
[Key, Column(Order = 2)]
[ForeignKey("CountLog")]
public long LogEntryID { get; set; }
[Key, Column(Order = 3)]
[ForeignKey("Register")]
public long RegisterId { get; set; }
public long Value { get; set; }
public virtual CountLog CountLog { get; set; }
public virtual Register Register { get; set; }
}
public class Register
{
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[Key, Column(Order = 1)]
public long RegisterId { get; set; }
[Key, ForeignKey("Device"), Column(Order = 2)]
public long DeviceSerial { get; set; }
[StringLength(50)]
public string RegisterName { get; set; }
public ContributionType Contribution { get; set; }
public virtual Device Device { get; set; }
public virtual ICollection<RegisterCountLog> CountLogs { get; set; }
}
誰能幫助?
這有什麼不同? – Chris 2014-09-23 11:10:23
答案已經更新。 – 2014-09-23 11:27:06