Hello,
If I disable Cascading delete in Code generation settings Cascading delete still is used:
I cannot see any difference if it is disabled or enabled in generated code:
public async Task<PDBIntern.Models.PDB.Bezirk> DeleteBezirk(int bezirkid)
{
var itemToDelete = Context.Bezirks
.Where(i => i.Bezirk_ID == bezirkid)
.FirstOrDefault();
if (itemToDelete == null)
{
throw new Exception("Item no longer available");
}
OnBezirkDeleted(itemToDelete);
Context.Bezirks.Remove(itemToDelete);
try
{
Context.SaveChanges();
}
catch
{
Context.Entry(itemToDelete).State = EntityState.Unchanged;
throw;
}
OnAfterBezirkDeleted(itemToDelete);
return itemToDelete;
}
robert
awalz
March 7, 2023, 11:59am
2
I think this is done in your DbContext.
Check your
protected override void OnModelCreating(ModelBuilder builder)
{
...
}
In the definition of you entities could be something like this for disabled cascading:
.OnDelete(DeleteBehavior.Restrict)
No, there is no difference if it is enabled/disabled and no OnDelete(DeleteBehavior.Restrict)
maybe a Bug in Balzor Studio?
robert
Chad
March 29, 2023, 5:30pm
4
I'm seeing the same thing as far as scaffolding with or without the cascade delete flag set does not change the code at all.
enchev
March 30, 2023, 5:57am
5
When cascade delete is enabled the Delete method in the service in Blazor server app and the ODataController in the WebAssembly app will have Include() for related entities:
I double checked our template and I've noticed that there are cases where the code will not be generated - the problem is fixed immediately and the fix will be part of our next update today/tomorrow.
1 Like
Chad
March 31, 2023, 4:06pm
6
Just FYI, confirmed it now works as expected in 1.8.0
Could you please add to the list of enhancements to save the prior setting?
I don't want cascade delete and am re-scaffolding often, every time I need to uncheck it rather that it remembering the setting from the last run.
Same for the CRUD configuration, would be great if remembered those values from the prior run.