0

Is it possible to add a cascading delete to an existing relationship using FluentMigrator. So could I replace the following two lines with a one-liner?

Delete.ForeignKey("FK_Attachments_Items").OnTable("Attachments");
Create.ForeignKey("FK_Attachments_Items").FromTable("Attachments").ForeignColumn("ItemId").ToTable("Items").PrimaryColumn("Id").OnDeleteOrUpdate(System.Data.Rule.Cascade);
Caltor
  • 2,538
  • 1
  • 27
  • 55

1 Answers1

1

It isn't possible to add a cascading delete rule to an existing relation because SQL doesn't support it. Which is why Fluent Migrator doesn't offer such functionality. It could offer a wrapper to recreate a foreign key with the cascading delete rule, but it doesn't. See this and this stackoverflow post for more information.

Vincent
  • 1,459
  • 15
  • 37