Why is there no update equivalent to WillCascadeOnDelete?

前端 未结 3 685
独厮守ぢ
独厮守ぢ 2021-01-19 04:21

When you\'re setting up a one:many relationship in EF code-first, you can choose whether it should cascade on delete like so:

modelBuilder.Entity

        
3条回答
  •  不思量自难忘°
    2021-01-19 05:01

    Well, apparently the answer to this is that you should never change the primary key in an ORM, even though DBMS's support the changing of the primary key. Because the assumption is that you will never change the primary key, there's no need for entity framework to allow you to specify whether to cascade on update, because the idea is that that primary key update will never happen.

    Note, though, that this can still be done manually in most databases even if the entity framework ORM doesn't let you do it that way. The DBMS will just use its default behaviour for a cascade update if you do the primary key update, manually, directly in the database.

提交回复
热议问题