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
Name | Value | Description |
---|---|---|
ClientSetNull | 0 | Sets foreign key values to |
Restrict | 1 | Sets foreign key values to |
SetNull | 2 | Sets foreign key values to |
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. |
NoAction | 5 | Sets foreign key values to |
ClientNoAction | 6 | Tracked dependents are not deleted and their foreign key values are not set 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://video2.skills-academy.com/dotnet/api/microsoft.entityframeworkcore.infrastructure.databasefacade.ensurecreated or https://video2.skills-academy.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