0

I found an issue but it refers to the BETA version of VS 2010. I am interested in knowing if this issue has been fixed in RTM?

Basically it states (saw it via EF 4 Self Tracking Entities does not work as expected )

Make certain to reuse the Self-Tracking Entity template’s generated entity code on your client. If you use proxy code generated by Add Service Reference in Visual Studio or some other tool, things look right for the most part, but you will discover that the entities don’t actually keep track of their changes on the client.

I am very used to using Add Service Reference, and its always worked great for me in the past but of course I wasn't using STE (Self tracking entities). Is this problem still apparent with VS 2010 RTM and the STE template?

If I do create the proxy via code instead of add service then all the classes won't be created will they?

halfer
  • 19,824
  • 17
  • 99
  • 186
Martin
  • 23,844
  • 55
  • 201
  • 327

1 Answers1

1

This is not an issue and it never was an issue. It is absolutly expected and correct behavior. STEs are classes which contains data and logic (the logic tracks changes).

When adding service reference your client proxy code is generated from service's metadata. Metadata are exposed in form WSDL. WSDL is XML based description of the service which also contains XSD description of transfered data types. XSD can describe only data format but not related logic implemented by the type. By default all unknown data types described in WSDL are generated on the client. So when you generate client proxy with all data types by Add service reference the tracking logic is lost.

To overcome this issue you have to do two things:

  • Create separate assembly and place all your STEs to this assembly. Then share this assembly among all involved layers (yes you have to use Add reference in your client).
  • Then you can use Add service reference with "Reuse types in referenced assemblies" checked.
John Saunders
  • 160,644
  • 26
  • 247
  • 397
Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
  • Thanks Ladislav, Implementing my types (ste) in an external assembly is what i wanted to do anyway so this is a plus for me. I suppose the magic is when using Add Service reference - the option Reuse types in referenced assemblied is what allows things to work. Can explain what the difference is between this and just doing an Add service reference ?? Thanks once again. – Martin Jan 09 '11 at 20:23
  • When using just add service reference without reusing your types, the generator creates new types in your client application. These types do not contain STE tracking logic. – Ladislav Mrnka Jan 09 '11 at 21:24