【发布时间】:2020-03-05 10:56:29
【问题描述】:
当我在包管理器控制台中更新数据库时出现此错误
在表“Appointments”上引入 FOREIGN KEY 约束“FK_dbo.Appointments_dbo.Users_AppointmentManagerId”可能会导致循环或多个级联路径。指定 ON DELETE NO ACTION 或 ON UPDATE NO ACTION,或修改其他 FOREIGN KEY 约束。 无法创建约束或索引。查看以前的错误。
我的课
[Table("Appointments")]
public class Appointment
{
#region property
[Key]
public int Id { get; set; }
[Required]
[MaxLength(200)]
public string Subject { get; set; }
[Required]
[MaxLength(500)]
public string Description { get; set; }
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy hh:mm tt")]
public DateTime StarTime { get; set; }
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy hh:mm tt")]
public DateTime EndTime { get; set; }
public String Location { get; set; }
#endregion
#region relationship
[ForeignKey("AppointmentCustomer")]
public int AppointmentCustomerId { get; set; }
[ForeignKey("AppointmentManager")]
public int AppointmentManagerId { get; set; }
public virtual Users AppointmentCustomer { get; set; }
public virtual Users AppointmentManager { get; set; }
#endregion
}
[Table("Users")]
public class Users
{
#region property
[Key]
public int Id { get; set; }
[Required]
public string IDUser { get; set; }
[Required]
public string Email { get; set; }
#endregion
#region relationship
[InverseProperty("TicketDeveloper")]
public virtual ICollection<Ticket> TicketDevelopers { get; set; }
[InverseProperty("TicketTester")]
public virtual ICollection<Ticket> TicketTesters { get; set; }
[InverseProperty("ProjectCustomer")]
public virtual ICollection<Project> ProjectCustomers { get; set; }
[InverseProperty("ProjectManager")]
public virtual ICollection<Project> ProjectManagers { get; set; }
[InverseProperty("NoteTester")]
public virtual ICollection<Note> NoteTesters { get; set; }
[InverseProperty("CaseCustomer")]
public virtual ICollection<Case> CaseCustomers { get; set; }
[InverseProperty("AppointmentCustomer")]
public virtual ICollection<Appointment> AppointmentCustomers { get; set; }
[InverseProperty("AppointmentManager")]
public virtual ICollection<Appointment> AppointmentManagers { get; set; }
#endregion
}
【问题讨论】:
标签: asp.net asp.net-mvc entity-framework-6 migration