12.13.2012

EF Code First Migrations Error on Foreign Key Constraints

Got this error message: Introducing FOREIGN KEY constraint 'FK_dbo.Emails_dbo.Certificates_CertificateId' on table 'Emails' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.

SOLUTION: Change the Up Method of the migration on the ForeignKey field as follows:
.ForeignKey("dbo.Creators", t => t.SenderId, cascadeDelete: false)
.ForeignKey("dbo.Certificates", t => t.CertificateId, cascadeDelete: false)
Change cascadeDelete to false.

No comments:

Post a Comment