Speak Personal All right!?
I'm going through the following problem in the entity framework that I think is some error I'm having at the time of relating two classes:
I have a class called: RequestPathPathIndexPath that is related to a class called Item, as shown below, I first made the relationship between them directly in the class, but since it was not working, I tried to do by Fluent API as below, I am able to save in the database of data normally but when I go to make an inquiry some items return normally but others do not. What can it be? I'm thinking it has to do with the fact that the relationship is with a string field and not a code, can that be it?
Below an image with the example of what is happening, in the same list some objects load and others do not, before they ask me all they exist in the bank and if I consult later they return ... it can be something with index or something like that?
publicclassSolicitacaoGarantiaItemPecas{[Key]publicintSolicitacaoGarantiaItemPecasID{get;set;}publicstringCodigoItem{get;set;}[ForeignKey("CodigoItem")]
public virtual Item ItemPeca { get; set; }
public decimal Quantidade { get; set; }
public int CodPedido { get; set; }
public string SituacaoPedido { get; set; }
public int SolicitacaoGarantiaItemID { get; set; }
[ForeignKey("SolicitacaoGarantiaItemID")]
public virtual SolicitacaoGarantiaItem SolicitacaoGarantiaItem { get; set; }
}
Fluent API:
modelBuilder.Entity<SolicitacaoGarantiaItemPecas>().HasRequired(a => a.ItemPeca).WithMany().HasForeignKey(c => c.CodigoItem);
Thank you! Alex