EntityFramework Migration cascadeDelete parameter

Viewed 4274

I'm using EF 4.3 migration feature to create database migration scripts. When I run Add-Migration command the generated script is created as so:

        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);

The problem I have is that the scafolding migration choose cascadeDelete to be true even though the entity Recipient is not the master of the relation.

For now I'm manually changing the cascadeDelete parameter to false but I would like to know why it choosing true by default.

Thank you, Ido.

2 Answers
Related