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();
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:
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: