2
我先使用Entity Framework 6代碼。我有三個實體這樣的:'PK_dbo.EntityName'不是一個約束。無法刪除約束.EF6
public class Doctor
{
public string DoctorID { get; set; }
public string firstName { get; set; }
public string lastName { get; set; }
}
public class ExpertiseDetails
{
[Key, Column(Order = 1)]
public short expertiseID { get; set; }
[Key , Column(Order = 2)]
public string DoctorID { get; set; }
[ForeignKey("expertiseID")]
public Expertise expertise { get; set; }
public Doctor doctor { get; set; }
}
public class Expertise
{
[Key]
public short expertiseID { get; set; }
public string expertiseTitle { get; set; }
}
我需要Expertise
和Doctor
之間的one to many
赫志,當我在控制檯nuGet
運行更新數據庫語句此錯誤顯示:
'PK_dbo.ExpertiseDetails' is not a constraint. Could not drop constraint
有什麼不對?
我想你有你的分貝數據,請刪除數據,然後再試 – Moein
@Moein。我嘗試了你的建議,但它不起作用! – Majid