Appendix B. ADO.NET XML Extensions

Appendix B. ADO.NET XML Extensions

Microsoft defines two namespaces for configuring DataSet schema files: codegen (urn:schemas-microsoft-com:xml-msprop) and msdata (urn:schemas-microsoft-com:xml-msdata). These namespaces extend the XSD format, allowing it to represent additional database-specific properties and allowing you to configure how typed DataSets are generated. In addition, the diffgr, or DiffGram namespace (urn:schemas-microsoft-com:xml-diffgram-v1), defines attributes that provide a way for XML documents to track DataSet changes and row insertions and deletions.

The structure of the XSD file for a DataSet is as follows:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="DataSetName">

  <xs:element name="DataSetName" >
      <xs:choice maxOccurs="unbounded">

        <xs:element name="DataTableName" >

              <xs:element name="FieldName" />



    <xs:unique name="ConstraintName" />
    <xs:keyref name="RelationName" />


The structure of the DiffGram format is shown next. All DiffGrams contains three sections: the current data, the original data, and any errors.

<?xml version="1.0"?>

  <!-- Data goes here. Changed rows are flagged. -->

     <!-- Contains the original data. -->

     <!-- Contains error information. -->


For specific examples that show how you can create a typed DataSet and refine its schema, refer to Chapter 4. For an introduction to the DiffGram format and XML serialization with the DataSet, refer to Chapter 7.

    Part I: ADO.NET Tutorial
    Part II: ADO.NET Core Classes
    Part III: API Quick Reference