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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:53:21+00:00 2026-06-06T14:53:21+00:00

Working on a project using Entity Framework (4.3.1.0). I’m trying to figure out how

  • 0

Working on a project using Entity Framework (4.3.1.0). I’m trying to figure out how to make my code work as a transaction, but for me it seems like my model doesnt update after the transaction has failed.

Let me show you:

using (TransactionScope trans = new TransactionScope())
{
    _database.Units.Add(new Unit{ ... });
    var a = false;
    if (a)
    {
        trans.Complete();
        Refresh();
    }
}

Refresh();

What I experience is that after the transactionscope is finished it doesnt roll back to it’s previous state. When I run the refresh method I iterate over all the items in Units and insert the values into a ObservableCollection which I display on the screen in a WPF window.

This mechanism works for when I successfully perform the transaction, but when I run the code above, the grid updates with the newly added Unit, but it does not go away after I run Refresh after the transaction.

I have the feeling I’m doing something fundamentaly wrong here 🙂

  • 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-06T14:53:22+00:00Added an answer on June 6, 2026 at 2:53 pm

    Entity Framework does not support transactions for the in-memory tracked entities – its “ObjectStateManager” which you see in the ObjectContext is not a transactional resource. The TransactionScope only “applies” to the database operations (queries, updates) done within it, not the in-memory operations, such as manipulating the object graph (which is what you do).

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

Sidebar

Related Questions

Im working on a MVC3 project using code first entity framework. On a webpage
I'm working on a personal project using WPF with Entity Framework and Self Tracking
I'm working on my first project, using Entity Framework. I've got a SQL Express
I am using Entity Framework in a project and I am trying to attach
While using the Entity Framework I have split it out to it's own project:
I am working on a new project and we are using Entity Framework and
I have an MVC 3 project that I am working on using Entity Framework
I have an issue with the project I'm working on. I'm using Entity Framework.
I'm currently working on a project using netbeans 6.9 and grails 1.3. I'm trying
I have been using Entity Framework CTP with Code-First as in this tutorial by

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.