for data contract,there will be different versions between the client and service since the time is going.there are three main versioning scenarios:
- New members
- Missing members
- Round trip
by default,data contracts are version tolerant and will silently ignore imcompatibilities.
both of the client and service can accept the data contract with new members which do not belong to the original contract.but how receiving sides deal with the new members? by default,just ignore the new member for the compatiblities, for the recieving side,the new member can not be found. which is just like the sending sides send the data contract that the recieving sides expect.
how about the missing members.by default,you can serialize the data without missing members and send it to another party which expects the missing members.the receiving side will not find the missing members and just deserialize the them to null for a reference type or zero for value type.
sometimes the missing members are essential for the receiving side,if the sending side misses such members, which will result in disastrous results,so how do we avoid this,we can decorate the members with setting the IsRequired property of DataMember attribute to true.if the sending side misses the members which are required in receiving side.there will be a runtime exception in the sending side.
Round trip here means keeping the new members when serializing and deserializing,but where the wcf store the new members,the solution is to have the datacontract implement the IExtensibleDataObject interface,which has a single property of type “ExtensionDataObject”,as a developer,we never have to interact with it directly,these object is used to store the new members.
but sometimes ,a service developer just wants to send his own data contract to client,he does not want to keep the new members, but the data contract has already implemented the ExtensionDataObject interface.the only way for this is to set the IgnoreExtensionDataObject attribute of ServiceBehavior attribute to true.(the default value of IgnoreExtensionDataObject attribute is false ).
the best pratice is that you should always have you data contract implement the ExtensionDataObject interface but set the IgnoreExtensionDataObject attribute of ServiceBehavior attribute to false(just keep the default value).