Skip to content

Instantly share code, notes, and snippets.

@LSViana
Created August 22, 2018 21:41
Show Gist options
  • Save LSViana/d6d7681dd9b9312444ce0231ff00b0ed to your computer and use it in GitHub Desktop.
Save LSViana/d6d7681dd9b9312444ce0231ff00b0ed to your computer and use it in GitHub Desktop.
// ASP.NET Framework
modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
// ASP.NET Core
foreach (var entityType in modelBuilder.Model.GetEntityTypes())
{
foreach (var navigation in entityType.GetNavigations())
{
navigation.ForeignKey.DeleteBehavior = DeleteBehavior.Restrict;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment