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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:30:26+00:00 2026-05-13T23:30:26+00:00

I’m using VS1010RC with the POCO self tracking T4 templates. In my WCF update

  • 0

I’m using VS1010RC with the POCO self tracking T4 templates.

In my WCF update service method I am using something similar to the following:

using (var context = new MyContext())
{
  context.MyObjects.ApplyChanges(myObject);
  context.SaveChanges();
}

This works fine until I set ConcurrencyMode=Fixed on the entity and then I get an exception. It appears as if the context does not know about the previous values as the SQL statement is using the changed entities value in the WHERE clause.

What is the correct approach when using ConcurrencyMode=Fixed?

  • 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-13T23:30:27+00:00Added an answer on May 13, 2026 at 11:30 pm

    The previous values need to be in your object.

    Let’s say you have a property ConcurrencyToken:

    public class MyObject
    {
        public Guid Id { get; set; }
        // stuff
        public byte[] ConcurrencyToken { get; set; }
    }
    

    Now you can set ConcurrencyMode.Fixed on that property. You also need to configure your DB to automatically update it.

    When you query the DB, it will have some value:

    var mo = Context.MyObjects.First();
    Assert.IsNotNull(mo.ConcurrencyToken);
    

    Now you can detach or serialize the object, but you need to include ConcurrencyToken. So if you’re putting the object data on a web form, you’ll need to serialize ConcurrencyToken to a string and put it in a hidden input.

    When you ApplyChanges, you need to include the ConcurrencyToken:

    Assert.IsNotNull(myObject.ConcurrencyToken);
    using (var context = new MyContext())
    {
      context.MyObjects.ApplyChanges(myObject);
      context.SaveChanges();
    }
    

    Having ConcurrencyMode.Fixed changes the UPDATE SQL. Normally it looks like:

    UPDATE [dbo].[MyObject]
    SET --stuff
    WHERE [Id] = @0
    

    With ConcurrencyMode.Fixed it looks like:

    UPDATE [dbo].[MyObject]
    SET --stuff
    WHERE [Id] = @0 AND [ConcurrencyToken] = @1
    

    …so if someone has updated the row between the time you read the original concurrency token and the time you saved, the UPDATE will affect 0 rows instead of 1. The EF throws a concurrency error in this case.

    Therefore, if any of this isn’t working for you, the first step is to use SQL Profiler to look at the generated UPDATE.

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

Sidebar

Ask A Question

Stats

  • Questions 335k
  • Answers 335k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Well you're asking this: "So I could copy and paste… May 14, 2026 at 3:38 am
  • Editorial Team
    Editorial Team added an answer In PHP, you can't call an arbitrary method on a… May 14, 2026 at 3:38 am
  • Editorial Team
    Editorial Team added an answer Here's a utility class I use. It can be used… May 14, 2026 at 3:38 am

Related Questions

I want use html5's new tag to play a wav file (currently only supported
In order to apply a triggered animation to all ToolTip s in my app,
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I've got a string that has curly quotes in it. I'd like to replace

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.