Disable cascading delete to global table for entity structure

Look for some help removing the Entity Framework cascade. First we turned off cascading deletion all over the world.

modelBuilder.Conventions.Remove<ManyToManyCascadeDeleteConvention>(); modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>(); 

Now we want to enable it. However, the problem arises that when creating a transfer, we get this error "may cause loops or several cascading paths."

The decision to use poor work API creates ..

  modelBuilder.Entity<Campus>() .HasRequired(c => c.Institution) .WithMany() .WillCascadeOnDelete(false); 

However, the Institution causes more than one problem, since the InstitutionId exists everywhere. I want you to not have to go through each option and ignore them in each case. Is it possible to stop cascading deletion for all relationships in the Institution table?

An institution is never deleted, so we are not opposed if it does not have a cascading deletion.

thanks

+5
source share

All Articles