Foreign key constraint, EF with collection of childobjects

后端 未结 4 1391
遥遥无期
遥遥无期 2021-01-27 09:31

I\'m trying to update a model, but get the error \"The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable.

4条回答
  •  清酒与你
    2021-01-27 09:43

    can you add the code for your event object. The one you call original.

    It might be so that the UpdateModel change some info on the associated objects and that's not good if so. Not sure about this though I can't see all the code.

    I prefer to not uder UptadeModel and instead use a inputmodel or your MVC model as the inparameter and manually map the chages to the loaded original object.

    Antoher problem is that I can't see if eventRepository.Save();

    really do an SaveShages? does it? I can se some context code in another method Save?

提交回复
热议问题