我正在使用EF 4.3迁移功能创建数据库迁移脚本。 当我运行Add-Migration命令时,生成的脚本如下:
CreateTable(
"dbo.Recipients",
c => new
{
RecipientID = c.String(nullable: false, maxLength: 128),
SurveyRoundID = c.String(nullable: false, maxLength: 128),
LastUpdatedAt = c.DateTime(),
})
.PrimaryKey(t => t.RecipientID)
.ForeignKey("dbo.Employees", t => t.EmployeeID, cascadeDelete: true)
.ForeignKey("dbo.SurveyRounds", t => t.SurveyRoundID, cascadeDelete: true)
.Index(t => t.EmployeeID)
.Index(t => t.SurveyRoundID);
我遇到的问题是,即使实体Recipient不是关系的主控方,脚手架迁移也选择将cascadeDelete设为true。
目前我正在手动将cascadeDelete参数更改为false,但我想知道为什么默认情况下选择true。
谢谢, Ido.