Cascade Delete Rule in EF 4.1 Code First when using Shared Primary Key Association

前端 未结 2 722
误落风尘
误落风尘 2020-12-10 07:17

I implemented a bidirectional 1:1 relationship based on this answer:

Primary /Foreign Key in Entity Framework

I define the bidirectional relation this way:

2条回答
  •  盖世英雄少女心
    2020-12-10 07:31

    Also, you can use [Required] Attribute, and it will automatically set the delete rule to "CASCADE" mode in related relationship. (and also set "Allow Null" property of that entity to "false" in DB)

提交回复
热议问题