A Template
can have zero or many Document
and zero or many MetaIndex
. A Document
can have zero or more Index
, and a MetaIndex
can also have zero or more Index
:
This represent a potential cascade problem because deleting a Template
will delete its Document
(which is OK); deleting a Document
will delete its Index
, which is also OK. But when deleting a Template
try to delete the MetaIndex
(which will also delete Index
) a problem will appear (a cycle).
I understand the problem. I think a way to solve it is specifying that when I delete a template it's documents and its document's indices get deleted, and also the meta-indices associated with the template. But that the metaindices do not cascade delete it's associated indices, so no cycles appear.
Searching here for a potential solution, I've tried this:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<MetaIndex>().HasMany<Index>(m => m.IndicesEnteros).WithRequired().WillCascadeOnDelete(false);
}
But it's not working:
Introducing FOREIGN KEY constraint on table may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints. Could not create constraint. See previous errors.