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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:21:52+00:00 2026-06-03T06:21:52+00:00

Say we have: public class Driver { public int driverID { get; set; }

  • 0

Say we have:

public class Driver
{
    public int driverID { get; set; }
    public byte[] stamp { get; set; }
    public string name { get; set; }
    public string prename { get; set; }
}

Now in short I`m facing this kind of situation.

 ...
 var myDriver = myCustomDBContext.Drivers.AsNoTracking()
                                         .Where(d => d.driverID == driverID)
                                         .SingleOrDefault();
 ...
 myDriver.name = "John";
 myDriver.prename = "Lennon";
 ...
 myCustomDBContext.Drivers.Attach(myDriver);
 myCustomDBContext.Entry(myDriver).State = EntityState.Modified;
 myCustomDBContext.SaveChanges();
 ...

And the result is

 The column cannot be modified because it is an identity, rowversion or 
     a system column. [Column name = stamp]

Is there any method which could force an Update on a detached entity, or a workaround for this rowversion column not to be set as Modified.

  • 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-03T06:21:53+00:00Added an answer on June 3, 2026 at 6:21 am

    It looks like you didn’t have specified the stamp property as a rowversion in your model and it is just a binary field. You can specify it with Fluent API:

    modelBuilder.Entity<Driver>().Property(d => d.stamp)
        .IsRowVersion()
        .IsConcurrencyToken(false);
    

    The code above is for the case when you don’t want to have the stamp property as a concurrency token. (A rowversion is a concurrency token by default, so you have to disable it explicitly.) If you want to have it as concurrency token, then you can use with Fluent API…

    modelBuilder.Entity<Driver>().Property(d => d.stamp)
        .IsRowVersion();
    

    …or with data annotations:

    [Timestamp]
    public byte[] stamp { get; set; }
    

    This should prevent EF to write an UPDATE for this property.

    Edit

    If you use Database-First strategy the [Timestamp] attribute does not work. This attribute is only for Code-First development.

    When you use Database-First the connection string contains a metadata section refering to the EDM defined in the EDMX file:

    connectionString="metadata=res://*/Model1.csdl
                              |res://*/Model1.ssdl
                              |res://*/Model1.msl;
                              ...
                              ..."
    

    If Entity Framework finds this section in the connection string it doesn’t use data annotations on model properties nor does it process any code in Fluent API (OnModelCreating isn’t called at all). Instead it loads the mapping definitions from the embedded and compiled EDMX file.

    That means, if you want to define the stamp property as a concurrency token you must do this in the EDMX file. In XML it would look like this:

    In SSDL section:

    <Property Name="stamp" Type="timestamp" Nullable="false"
              StoreGeneratedPattern="Computed" />
    

    In CSDL section:

    <Property Name="stamp" Type="Binary" Nullable="false" MaxLength="8"
              FixedLength="true"
              annotation:StoreGeneratedPattern="Computed"
              ConcurrencyMode="Fixed" />
    

    You can also define this in the model designer in Visual Studio: Mark the stamp property in the entity in the designer surface, go to the Properties Window and set “Concurrency Mode” to “Fixed” (and also set the “StoreGeneratedPattern” to “Computed”).

    You can also remove the metadata section from the connection string. But this effectively means that you switch from database first to code first development. Then all attributes and Fluent API will be respected, but not any definitions in EDMX anymore.

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

Sidebar

Related Questions

Let's say I have: public class Item { public string SKU {get; set; }
Say I have: public class Event { public int EventID { get; set; }
Say Suppose you have a class public class Person { public int PesronId{get;set;} public
Say I have public class Person { int id; String regDate; String name; String
Say I have this class: public class Account { public int AccountID { get;
Let's say I have: public class Fruit { public static List<String> Suppliers { get;
Say you have this: public class ShoppingCart { public IList<CartItem> cartItems {get; set; }
let's say i have this public class MyClass { public string myMessage { get;
Let's say I have: public class Components<T> extends TupleList<Class<T>, String> { private static final
Simple question on best practice. Say I have: public class Product { public string

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.