Entity Framework: A referential integrity constraint violation on many to many relationship

后端 未结 6 1288
一向
一向 2020-12-15 15:27

Hey I have an application with a bunch of inproc caching and entity framework. When I want to write an update to an entity I reattach the cached copy. I track all things I\'

6条回答
  •  没有蜡笔的小新
    2020-12-15 16:21

    @LukeMcGregor hi,

    I think I can offer a different perspective as someone who has the same problem.

    After I have performed all the necessary checks, I can say that I prefer to get this error.

    Because in my scenario: I wanted to include an object that caused a mismatch error. It's the location object in your scenario. If I add an object with an ID, I get this error because the ID in the previous object (the one that is not updated) does not match the updated ID.

    But it's not a big problem. As a solution; If it is still on the UI side, the object may still be included if it still exists.

    You will either empty the object when you receive the update request from the user. (= Null) Or you will update the object with the ID updated by the user before the service-side update (attach, modified ... whatever) and update it in this way.

    That's it. It can remain as it is in the database and diagrams.

提交回复
热议问题