Created
August 22, 2018 21:41
-
-
Save LSViana/d6d7681dd9b9312444ce0231ff00b0ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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