0

I am not using Entity Framework 4. I am on Visual Studio 2008.

I have a model that has items of type EntityCollection & EntityReference.

I am able to make changes to other properties (string, int, etc) of the model using the ApplyPropertyChanges. But I don't know exactly how to update EntityCollection & EntityReference items of the same model object.

Eg:

Note has following items

{

String Name;
EntityCollection<Links> NoteLinks;
Reminders NoteReminders;
EntityReference<Reminders> RemindersReference;

}

When a record already exists, I can update Name easily. How exactly should I update NoteLinks & NoteRemindersReference?

I have seen many examples on StackOverflow but they are either not addressing the same problem or they are implemented in EF4 which I am not using.

Please help.

Gautam Jain
  • 6,789
  • 10
  • 48
  • 67

1 Answers1

2

I think you are using detached objects because otherwise you would not get these problems. There is actually almost no difference between behvior of EFv1 and EFv4. I described general problems here. The question was about POCO and EFv4 but the same conclusion if for detached entity objects in EFv1. If you have detached entity graph and you want to merge changes to attached object you can't use ApplyPropertyChanges. That method is only able to update scalar properties. You must merge navigation properties manually.

Community
  • 1
  • 1
Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670