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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:15:22+00:00 2026-06-04T14:15:22+00:00

I used Attach method to update my Database name=New Name; checkBox1=false; Entity entity= new

  • 0

I used Attach method to update my Database

     name=New Name;
     checkBox1=false;
     Entity entity= new Entity();
        entity.ID= collection.ID;
        db.entities.Attach(entity);
        entity.name=name;
        entity.checkBox1=checkBox1;
        db.SaveChanges();

This query updated only name column of desired table, but with checkBox1 value it did nothin…
Why is there anything i am doing wrong or this is a bug?

Issue is resolved by using below query syntex.

    var entity= db.entities.Find(ID);
    entity.name=name;
    entity.checkBox1=checkBox1;
    db.SaveChanges();
  • 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-04T14:15:23+00:00Added an answer on June 4, 2026 at 2:15 pm

    This issue could occur if you have switched AutoDetectChanges off, heres a post I wrote on what AutoDetectChanges does: http://blog.staticvoid.co.nz/2012/05/entityframework-performance-and.html

    If you have this option off and attach an entity the snapshot engine may not be able to find property changes. Try manually calling detect changes before you save. You can use the following:

    db.ChangeTracker.DetectChanges();
    

    Another possible issue is that the snapshot engine thinks that the initial state of the checkbox1 property is false this means that it will not register the change when you set the value to false. To get around this issue set the initial value of checkbox1 to true then set it to false after the attach. This will ensure the value changes and hence is detected by snapshotting.

    eg use:

    name=new Name();
     checkBox1=false;
     Entity entity= new Entity();
        entity.ID= collection.ID;
        entity.checkBox1=!checkBox1;
        db.entities.Attach(entity);
        entity.name=name;
        entity.checkBox1=checkBox1;
        db.SaveChanges();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used below code to attach quckboook events // Subscribe to UI events...
I am used to jQuery , which has a delegate() method. So let's say
Source I've never used C before. this script adds a listener onto a directory
The goal: I'm trying to use the new Entity Framework 4.1 DbContext API (using
I'm used to using code first where I can do: db.Users.Attach(user); db.Entry(user).Property(propertyName).IsModified = true;
I want to attach a event to dynamically created element class.So i used live
here i attach a sample code. they used JavaScriptSerializer to generate data in json
So I have a method that implements IHttpHandler.ProcessRequest. It accepts an HttpContext parameter. This
I am using MVC 3 with Entities, now I have used the below line
Has anyone of you ever used php_writeexcel (http://www.bettina-attack.de/jonny/view.php/projects/php_writeexcel/)? I would like to know if

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.