【发布时间】:2016-12-27 18:08:00
【问题描述】:
我首先使用的是 Entity Framework 6 代码。我有三个这样的实体:
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 。我尝试了你的建议,但它不起作用!
标签: c# entity-framework-6 code-first