Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9198613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:19:37+00:00 2026-06-17T22:19:37+00:00

I have the table A and Table B: TableA(IDTableA,…) TableB(IDTableB, IDTableA,…) I know that

  • 0

I have the table A and Table B:

TableA(IDTableA,...) TableB(IDTableB, IDTableA,...)

I know that I can delete on cascada if I set this on the database, but if I haven’t defined this in the database and I want to delete the children with EF, which is the best way to do that?

Imagine this situation: user A add to the context the parent, user A add the childs to context, mark the parent and the children as deleted and save the changes. But if an user B add a new child between the time user A loads the children and confirm the changes, the new child added by the user B is not deleted, or I get an exception because of reference integrity.

I try to use a transaction, to set the parent as deleted, then, in the next step, when I make the savechanges, the parent register is locked, so can’t be load by other user. But the problem is the same, other user can make changes in the parent between the parent is load and the save changes.

So my question is, if I want to delete the parent and all its children with EF, which is the best way? The best way is try N times delete the parent? is this a good option when I wnat a good performance?

Thanks.
Daimroc.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:19:39+00:00Added an answer on June 17, 2026 at 10:19 pm

    In this particular case I think that the best way is to use a trigger to delete de childs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view with this information: TableA (IDTableA, IDTableB, IDTableC, Active, date, ...)
In ms-access database i have a table named tableA this table has a column
I have a table in my database (TableA) that has a column (TableA.Column1) that
I have a table (let's call it tableA) that looks something like this: id
I have a table, TableA, that looks like this: ColA ColB 0 20 1
I have this table (TableA): ( [FieldA] [int] NOT NULL, [FieldB] [int] NOT NULL,
I have a table called TableA whch has a foreign key from TableB and
Let say that I have table TableA(ColumnCode, ColumnA2, ColumnA3, ColumnA4, ColumnA5). Note: ColumnCode(PrimaryKey)is not
I have two tables : TableA TableB id id amt amt idUser idTableA Let's
I have a simple SQL Server 2008 database with two tables like this: TableA:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.