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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:11:44+00:00 2026-06-03T05:11:44+00:00

I have an entity retrieved from db as follows using ( var ctx =

  • 0

I have an entity retrieved from db as follows

using ( var ctx = new Mycontext() )
   return ctx.MyGroups.First( // query );

this is bound to UI and updated on user save action as follows

using ( var ctx = new Mycontext() )
{
    ctx.MyGroups.Attach(o); // verified object o is updated 
    ctx.SaveChanges();

}

However the db is NOT updated

Environment is .net 4.0, db is sql compact 4

Any help on what could be missing/wrong ?

  • 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-03T05:11:45+00:00Added an answer on June 3, 2026 at 5:11 am

    When you attach objects to the context, their default state is Unchanged, you should force the update by setting DBContext.Entry(entity).State = EntityState.Modified; And only after that call DBContext.SaveChanges();

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

Sidebar

Related Questions

I am using LINQ-to-SQL. I have retrieved an Entity called FileType using FileTypeID from
I have two entity lists being retrieved from the database they are using the
I have entity model like this (using EclipseLink and JPA 2.0): @Entity class A
I have a entity that I retrieve as follows and is detached from the
I have two @Entity s, both with a BigDecimal field as follows: in one
I'm using a PersonEditHandler class in tipfy to edit a Person entity. I have
I have a XML String retrieved from a XML file. I can't access the
I have an object from inside a Symfony2 project. Here follows the code. namespace
I'm having trouble mapping two entities together with Entity Framework CTP5 using Code First
I am using Entity Framework 4.1 - Code First. I store user's addresses as

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.