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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:34:48+00:00 2026-05-23T02:34:48+00:00

I will be more specific here.. This is a strange problem and really, i

  • 0

I will be more specific here..
This is a strange problem and really, i am not understanding why this is happening..

In my data model every table has a column of type rowversion, and in my EDM (Entity Data Model) i enabled version to be my rowversion and maps exacly with my column rowversion in database.

Here is the problem.

1) I List items
2) I go update one item, (supose with id 4)
3) I send to the form in a hiddenfield the value of the rowversion
4) Someone updated in database some field in id 4 (making the rowversion to change)
5) I update the new values
6) i Convert string data with rowversion to byte[]
7) I get the object with primary key from the database and affect all properties of the object returned from database with model binded object that come from the form post including the rowversion!
8) I invoke SaveChanges()
9) The Problem!

I go to profiler and i see that the query that is build contains the Newer version and not the older (not that i affected from the post form to the object that come from the database).

For me appears that EF when is building is using the newVersion in some place, and not uses the current value that controls concurrency in the object..

Somebody know what it is happening????

  • 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-05-23T02:34:49+00:00Added an answer on May 23, 2026 at 2:34 am

    Here is my workaround..
    for persistance ignorant:

           public void Update<TEntity>(TEntity Entity) where TEntity : class {
                ObjectStateEntry entry = _Context.ObjectStateManager.GetObjectStateEntry(Entity);
                entry.ChangeState(EntityState.Modified);
                entry.AcceptChanges();
                entry.ChangeState(EntityState.Modified);
            }
    

    The essence is..

    POCO don’t notify the context for changes, so when i update an entity, the entry still remains unchanged.

    1) I get the entry with Entity passed in the method
    2) I change the state to Modified
    3) I call AcceptChanges.. (note that in step 2 i changed the state to modified, so AcceptChanges now copies the CurrentValues to OriginalValues.. - Looks that implementation of AcceptChanges just procede if the state are different than Unchanged and makes sence)
    4) I got the values copied but the default behavior of acceptChanges is let the state Unchanged..
    5) I change the state to modified, so the SaveChanges can build the Update Command.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question could easily take multiple paths, so I will hit the more specific
I am not trying to spam here just trying to be more specific about
If the number of documents is more will the querying of data gets slower
If so why? I know setting this on will result in more number of
Here is more specific explanation of what I want to make clear: I have
I have asked aqbout timezones and date/time before but this is a more specific
To be more specific, How do I validate that a model requires at least
I'm not going to get specific here with code, because I don't feel like
in the code below at first if statements block (there will be more than
I've heard that the components in the upcoming Flex 4 framework will be more

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.