Entity framework and inheritance: NotSupportedException

前端 未结 3 1275
暖寄归人
暖寄归人 2021-02-20 16:02

I\'m getting

System.NotSupportedException: All objects in the EntitySet \'Entities.Message\' must have unique primary keys. However, an instance of

3条回答
  •  面向向阳花
    2021-02-20 16:43

    It sounds like you are pulling two records into memory one into message and one into comment.

    Possible prblems:

    • There are two physical messages with the same id
    • The same message is being pulled up as a message and a comment
    • The same message is being pulled up twice into the same context

    That the problem sometimes goes away when you restart, points to a problem with cleaning up of context. Are you using "using" statements.

    Do you have functionality for changing from a message to a comment?

提交回复
热议问题