Why inheritance is not suggested for DataContract versioning RRS feed

  • Question

  • Hi guys, as the MSDN article <Best Practices: Data Contract Versioning> said:

    "The use of inheritance together with data contracts is allowed, provided that inheritance is not used as a versioning mechanism and that certain rules are followed."

    I don't understand why inheritance should not be used as a versioning mechanism? Can someone show me an example?

    Monday, November 23, 2015 4:35 PM


  • Hi Charley_Chen,

    As far as I know, description of the data structure that is used to Exchange data contract,

    and is the basis for data serialization and deserialization. In a WCF application, client and

    server must be equivalent to the data contract in order to be effective exchange data.

    If we used inheritance to be a versioning mechanism, In general, using data members with

    the same names at different levels of the same inheritance hierarchy can lead to serious

    versioning problems and should be avoided. Because when we serialize it, the data structure

    would be changed.

    For more information, please refer to the following articles:

    1.DataContract with inheritance change

    Best Regards,


    Wednesday, November 25, 2015 6:08 AM