0
I have My Repair and Repair Table and I’m getting the following msg when I try to update my Migration: "The introduction of the FOREIGN KEY restriction 'Fk_dbo.Fixeddbo.Pecas_pecasid' in the 'Fix Settings' table can cause cycles or several cascading paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY restrictions. Could not create constraint or index. See previous errors."
public class Conserto
{
[Key]
public int Id { get; set; }
public DateTime DataEntrada { get; set; }
public string NomeCliente { get; set; }
public string NomeFuncionario { get; set; }
public string NomePeca {get;set;}
public string DescricaoDefeito { get; set; }
public string DescricaoSolucao { get; set; }
public decimal ValorMaoObra { get; set; }
public decimal ValorTotalConserto { get; set; }
public int PecasId { get; set; }
public int ClienteId { get; set; }
public int FuncionarioId { get; set; }
[ForeignKey("PecasId")]
public virtual Pecas Pecas { get; set; }
[ForeignKey("ClienteId")]
public virtual Cliente Cliente { get; set; }
[ForeignKey("FuncionarioId")]
public virtual Funcionario Funcionario { get; set; }
}
Conserdetalhes
public class ConsertoDetalhes
{
[Key]
public int Id { get; set; }
public int ConsertoId { get; set; }
public int PecasId { get; set; }
public decimal Total { get; set; }
[ForeignKey("ConsertoId")]
public virtual Conserto Conserto { get; set; }
[ForeignKey("PecasId")]
public virtual Pecas Pecas { get; set; }
}
You put this model together yourself ? you really need the ( public int Pecasid { get; set; } ... public int Clienteid { get; set; } ... public int Funcionarioid { get; set; } ... and create public virtual Pecas Pecas { get; set; } ?
– Marco Souza
yes because when I’m creating, I need to have access to parts list, employee and customer.
– Cesar Augusto