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 8032915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:32:08+00:00 2026-06-05T01:32:08+00:00

I have three tables – Context, Session and User. And below are their simplified

  • 0

I have three tables – Context, Session and User. And below are their simplified structure.

User:
UserId (Int, PK)
Email (Varchar(100))

Context:
ContextId (Int, PK)
UserId (Int, FK from User table)
CurrentSessionId (Int, Nullable, FK from Session table)

Session:
SessionId (Int, PK)
UserId (Int, FK from User table)
ContextId (Int, FK from Context table)

Below is the sequence in my code to delete a user entity.

1) Update CurrentSessionId of Context table to null where UserId = UserId to be deleted.
2) Delete all Sessions corresponding to the User
3) Delete all Contexts corresponding to the User
4) Finally Delete User.
5) Call ObjectContext.SaveChanges()

Upon calling ObjectContext.SaveChanges() I get the following exception –

Unable to determine a valid ordering for dependent operations. Dependencies may exist due to foreign key constraints, model requirements, or store-generated values.

I guess EF4 gets confused determining the execution order of first 3 statements. Is it possible to tell EF4 what statements to execute first and what to execute next?

One way I can work around is to call SaveChanges() after step one and then call it again after step four. But I would love to know if there are any other elegant solution than that.

  • 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-05T01:32:11+00:00Added an answer on June 5, 2026 at 1:32 am

    Based on this MSDN link the order of execution cannot be forced in EF4. I had to call SaveChanges() twice once after step one and then again after step four.

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

Sidebar

Related Questions

I have three tables: User: UserId (pk) FirstName Lastname Messages: MessageId (pk) Heading Body
I have three tables: Table User( userid username) Table Key( userid keyid) Table Laptop(
I have three tables: table "package" ----------------------------------------------------- package_id int(10) primary key, auto-increment package_name varchar(255)
I have three tables specifying important columns below Users(Id, username) Groups(Id, groupname, creator) (creator
I have three tables, table one (tableA) containing users data like name and email,
I have three tables: categories, articles, and article_events, with the following structure categories: id,
I have three tables: Context, Component and ComponentContext. The ComponentContext table links the Component
I have three tables: Campus Building Floor and table structure is looks like this:
I have three tables and my requirement is to fetch their records by using
I have three tables: user(id, name); tasks(id, user_id, text, date); bonus(id, user_id, sum, date,

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.