0

Hi I am developing a project with EF 4. I am trying to implement POCO Self Tracking do I need to implement a wcf service? I am having issues with modifying the entities as the changes are not persisted to the db.

Thanks in advance.

Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
markpcasey
  • 559
  • 1
  • 10
  • 18

1 Answers1

0

No you don't need service but if you don't use the service you should manually say to self tracking entity that it must start tracking changes by calling StartTracking

I explained purpose of self tracking entities in another answer. If you don't need detaching self tracking entities from the context you should use POCOs. Attached self tracking entity works as POCO but it looses some features - for example lazy loading because self tracking entities are not proxied.

Using self tracking entities with WCF makes sense only if you have control over the client and client is written in .NET. I also described this in another answer.

You probably don't need STEs.

Community
  • 1
  • 1
Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
  • Thanks for your answer. After plenty of messing around. I sorted the issue by calling context.DetectChanges(). I found that the StartTracking & MarkAsModified() were not working but this resolved it. I just need to call DetectChanges() and there is no need for StartTracking & MarkAsModified(). Do you know the difference between MarkAsModified() & DetectChanges(). Thanks – markpcasey May 12 '11 at 11:10
  • How do you use self tracking entities? `DetectChanges` works only if entity is not detached from the context and in such case there is no need for self tracking entities. – Ladislav Mrnka May 12 '11 at 11:26
  • Thanks. I am using a Repository & UnitofWork Pattern. I was unclear and thought that self tracking was necessary. By your feedback POCO would be fine. Would you reccomend leaving the self tracking POCO in place so if I decide to expose via WCF I can? – markpcasey May 12 '11 at 12:31