Hi @David Thielen , Welcome to Microsoft Q&A.
After testing, I added five sets of data to the table, and the deletion was successful through the following code.
using(var context = new MyDbContext())
{
var parentOrganization = await context.organization.Include(x => x.Children).OrderBy(x => x.Id).FirstAsync();
// Remove parent reference from child organizations
foreach (var child in parentOrganization.Children)
{
child.Parent = null;
}
context.Remove(parentOrganization);
context.SaveChanges();
}
Best Regards,
Wenbin
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.