データベース移行スクリプトを作成するために 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);
私が抱えている問題は、エンティティの受信者が関係のマスターではないにもかかわらず、スキャフォールディングの移行が cascadeDelete を true に選択することです。
今のところ、cascadeDelete パラメータを手動で false に変更していますが、デフォルトで true を選択する理由を知りたいです。
ありがとう、イド。