Class CascadeDeleteConvention
- Namespace
- Microsoft.EntityFrameworkCore.Metadata.Conventions
- Assembly
- Microsoft.EntityFrameworkCore.dll
A convention that sets the delete behavior to Microsoft.EntityFrameworkCore.DeleteBehavior.Cascade for required foreign keys and Microsoft.EntityFrameworkCore.DeleteBehavior.ClientSetNull for optional ones.
public class CascadeDeleteConvention : IForeignKeyAddedConvention, IForeignKeyRequirednessChangedConvention, IConvention
- Inheritance
-
CascadeDeleteConvention
- Implements
- Inherited Members
Remarks
See Model building conventions for more information and examples.
Constructors
CascadeDeleteConvention(ProviderConventionSetBuilderDependencies)
Creates a new instance of CascadeDeleteConvention.
public CascadeDeleteConvention(ProviderConventionSetBuilderDependencies dependencies)
Parameters
dependencies
ProviderConventionSetBuilderDependenciesParameter object containing dependencies for this convention.
Properties
Dependencies
Dependencies for this service.
protected virtual ProviderConventionSetBuilderDependencies Dependencies { get; }
Property Value
Methods
GetTargetDeleteBehavior(IConventionForeignKey)
Returns the delete behavior to set for the given foreign key.
protected virtual DeleteBehavior GetTargetDeleteBehavior(IConventionForeignKey foreignKey)
Parameters
foreignKey
IConventionForeignKeyThe foreign key.
Returns
- DeleteBehavior
ProcessForeignKeyAdded(IConventionForeignKeyBuilder, IConventionContext<IConventionForeignKeyBuilder>)
Called after a foreign key is added to the entity type.
public virtual void ProcessForeignKeyAdded(IConventionForeignKeyBuilder relationshipBuilder, IConventionContext<IConventionForeignKeyBuilder> context)
Parameters
relationshipBuilder
IConventionForeignKeyBuilderThe builder for the foreign key.
context
IConventionContext<IConventionForeignKeyBuilder>Additional information associated with convention execution.
ProcessForeignKeyRequirednessChanged(IConventionForeignKeyBuilder, IConventionContext<bool?>)
Called after the requiredness for a foreign key is changed.
public virtual void ProcessForeignKeyRequirednessChanged(IConventionForeignKeyBuilder relationshipBuilder, IConventionContext<bool?> context)
Parameters
relationshipBuilder
IConventionForeignKeyBuilderThe builder for the foreign key.
context
IConventionContext<bool?>Additional information associated with convention execution.