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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:18:19+00:00 2026-06-18T04:18:19+00:00

I have table(and also entity in Entity Data Model) Person with following fields: Name

  • 0

I have table(and also entity in Entity Data Model) Person with following fields:

Name              Type
SocialID          String      
FirstName         String
LastName          String

which SocialID is Primary Key. I want to update value of SocialID for each record. However when i try to update this field in Entity Framework I get following error:

The property 'SocialID' is part of the object's key information and cannot 
be modified.

The code that i get above error is:

foreach (var p in Entity.Persons)
{
   p.SocialID= p.SocialID + "00";
   Entity.SaveChanges();
}

How I can do this??

  • 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-18T04:18:20+00:00Added an answer on June 18, 2026 at 4:18 am

    As mentioned by the others, you can’t do it in code. You will have to make your update in SQL. Either in a migration or directly in SQL Server Management Studio (or the equivalent if you’re using a different database).

    UPDATE Person -- Or 'Persons' if that's what your table is called
    SET SocialID = SocialID + '00'
    

    It will require a lot more work than this if you have other tables use this column as a foreign key (you’ll have to drop the constraints first — on all tables that reference your primary key — then fix the data and recreate the constraints). Or as Moe said in the comments, you can set your foreign keys to cascade on update.

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

Sidebar

Related Questions

We have a simple Table per Type Entity Framework 4.0 model :- ALl classes
I'm trying to add an object created from Entity Data Model classes. I have
I have a dynamic data model with potentially thousands of entity tables, let's call
I have a standard self referencing table of Categories . In my entity model
I have a database 'Sample' with a table 'User' with columns 'FirstName', 'LastName', 'Category'.
I have a model with following structure: Document entity has many Commands Command belongs
I have generated the data table model using the option Generate model from database
I have a data model like this in SQL Server: table Note - varchar
I have a table called userstbl that has supId (supervisor) and has also userID
I have a table that has an AUTO_INCREMENT field. Currently, it is also a

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.