Can't update foreign key reference(navigation property)?

Remove checkReferencies because: List in your example is not modified so the first part of the method will not be executed. The Product cannot be converted to Category and attached to DbSet. It will throw exception.

Category is already attached in Addes state (which is wrong because it will insert category again). Attaching entity again will throw the exception. Just attach both Category and Product to context from listRepository before you set them in List.

Or better completely rewrite your code and share context among repostiories.

Thanks for all the suggestions! I try to modify it and I hope to solve it! I'm pretty sure that I'll need your help :P!

– stuzzo Mar 15 at 14:26 You're totally right! I deleted all my code and I rewrite it with your suggestions! Thanks for your help!

Sorry, if I posted a terrible code! – stuzzo Mar 16 at 13:25.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions