RIA Services / EF. Changes to bool field in a derived class are not saving to database
We are using EF with RIA services. A simple application. Load a list of items, browse/edit/save. The problem is that some of the changes are not persisting to the db.
I have a model with the following
Person
...
string Name
bool IsActive
Customer : Person
...
string Address
bool IsLocal
Changes made to a Person save correctly.
When changing a Customer, if I change the IsLocal value to true, it saves correctly. If I change it to false, the change is not persisted to the database.
- Boiler plate generated code, no customizations
- No error messages. As far as the submit op is concerned, all went well.
- Changes to Address save correctly
- If I change the Address and set IsLocal, both save correctly.
- If I change the Address and clear IsLocal, the address saves but IsLocal stays set.
- Changes to IsActive (in Person) always save correctly, whether clearing or setting.
- I have recreated the problem in another solution with different tables.
- Seems to be the same problem, cannot clear bool/bit field in a derived class.
Any help开发者_开发知识库 that people can offer would be appreciated.
Thanks, Alan.Ok, I got a solution that is working for me...
I replaced the generated code for the Update method from:
this.ChangeSet.AttachAsModified( entity, this.ChangeSet.GetOriginal( entity ) );
for
this.ChangeSet.Attach( entity );
this.ObjectContext.ChangeObjectState( entity, EntityState.Modified );
Hope this helps!
精彩评论