Reduce impact of model changes

Issues where the model on the server gets misaligned with the model in your client side proxy (generated from Add Service Reference) can occur because the WorkZone OData model is generated automatically at runtime to include all the available entities and properties including all customizations and modules (products).

Model misalignment between server and client can occur in the following situations:

  • You generate the proxy against one WorkZone installation and run your code against another installation and the two installations are not identical (in terms of the underlying database).
  • You upgrade from one version of WorkZone Content Server to a newer release and the new release has additions to the underlying database.
  • You install a new WorkZone module or product that includes changes to the model.

If one of these situations occur, issues may arise during querying because the server might be sending a new property that does not exist in your proxy because the proxy was generated at a point where the new property did not exist.

A model misalignment manifests as an InvalidOperationException during object materialization stating “The closed type [X] does not have a corresponding [Y] settable property”.

To remedy this, you can perform an “Update Service Reference” and then recompile your code, but you can also make your code more immune to this situation by setting the DataServiceContext to ignore properties that are not present in the proxy.

To set DataServiceContext to ignore properties that are not present in the proxy, add this line to your code:


		context.IgnoreMissingProperties = true;
				

Kopibilledet mangler

Tip: It is recommended to always set the IgnoreMissingProperties to true.

It is also recommend to always include a projection for your results, not only for for performance reasons, but also to circumvent materialization problems with server model changes.