You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature request - ability to configure cascade delete on client side only (application server), without having cascade delete in Db.
When having aggregate root with all its includes in memory and remove just the root entity from context - all included entities should be marked for delete (EntityState.Deleted ).
Possible solution - add additional DeleteBehaviors:
DeleteBehavior.CascadeInClient which will not expect (and generate trough migrations) ON DELETE CASCADE to be present in the Db.
Steps to reproduce - Example:
//modelclassParent{publicintId{get;set;}publicChildChild{get;set;}}classChild{publicintId{get;set;}// Pk & Fk to Parent}// configurationmodelBuilder.Entity<Parent>().HasOne(e =>Child).WithOne().HasForeignKey<Child>().OnDelete(DeleteBehavior.CascadeInClient);// example codevarmodel=context.Set<Parent>().Single(e=>e.Id==1).Include(e=>e.Child);context.Remove(model);context.SaveChanges();// This should set EntityState.Deleted to both model & model.Child and compose query to delete them from Db, without having cascade delete inside Db.// This should be applicable to One-to-Many also.// Migrations should create db tables with ON DELETE RESTRICT
####Workarounds
Use reflection to recursively iterate over loaded navigation properties and set EntityState.Deleted on all child entities.
Further technical details
EF Core version: 2.0
Database Provider: Sql server & PgSql
Operating system: Windows 8.1
IDE: (e.g. Visual Studio 2017 15.4)
The text was updated successfully, but these errors were encountered:
Feature request - ability to configure cascade delete on client side only (application server), without having cascade delete in Db.
When having aggregate root with all its includes in memory and remove just the root entity from context - all included entities should be marked for delete (EntityState.Deleted ).
Possible solution - add additional DeleteBehaviors:
DeleteBehavior.CascadeInClient which will not expect (and generate trough migrations) ON DELETE CASCADE to be present in the Db.
Steps to reproduce - Example:
####Workarounds
Use reflection to recursively iterate over loaded navigation properties and set EntityState.Deleted on all child entities.
Further technical details
EF Core version: 2.0
Database Provider: Sql server & PgSql
Operating system: Windows 8.1
IDE: (e.g. Visual Studio 2017 15.4)
The text was updated successfully, but these errors were encountered: