DeleteBehavior Enum
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Indicates how a delete operation is applied to dependent entities in a relationship when the principal is deleted or the relationship is severed.
public enum DeleteBehavior
type DeleteBehavior =
Public Enum DeleteBehavior
- Inheritance
-
DeleteBehavior
Fields
Cascade | 3 | Automatically deletes dependent entities when the principal is deleted or the relationship to the principal is severed, and creates creates a foreign key constraint in the database with cascading deletes enabled. This is the default for required relationships. |
ClientCascade | 4 | Automatically deletes dependent entities when the principal is deleted or the relationship to the principal is severed, but creates a non-cascading foreign key constraint in the database. |
ClientNoAction | 6 | Tracked dependents are not deleted and their foreign key values are not set to |
ClientSetNull | 0 | Sets foreign key values to |
NoAction | 5 | Sets foreign key values to |
Restrict | 1 | Sets foreign key values to |
SetNull | 2 | Sets foreign key values to |
Remarks
Behaviors in the database are dependent on the database schema being created appropriately. The database is created appropriately when using Entity Framework Migrations or using one of https://learn.microsoft.com/dotnet/api/microsoft.entityframeworkcore.infrastructure.databasefacade.ensurecreated or https://learn.microsoft.com/dotnet/api/microsoft.entityframeworkcore.infrastructure.databasefacade.ensurecreatedasync .
See Cascade delete and deleting orphans in EF Core for more information and examples.
Applies to
Entity Framework