我正在使用EF 4.3遷移功能來創建數據庫遷移腳本。 當我運行Add-轉移命令生成的腳本創建爲這樣:EntityFramework遷移cascadeDelete參數
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);
我的問題是,scafolding遷移選擇cascadeDelete是真實的,即使實體收件人不屬於關係的高手。
現在我手動將cascadeDelete參數更改爲false,但我想知道爲什麼它默認選擇true。
謝謝, 伊多。
您是否知道如何在遷移中不使用含有'Sql(..)'的DDL定義'ON DELETE SET NULL'? – JoeBrockhaus 2015-07-22 22:51:03