<?xml version="1.0" encoding="UTF-8"?>
<!-- =====================================================================================
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the repository root for full copyright notice.
========================================================================================== -->
<ECSchema schemaName="ECDbMeta" alias="meta" version="04.00.03" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.3.2">
    <ECSchemaReference name="ECDbMap" version="02.00.04" alias="ecdbmap"/>

    <ECEntityClass typeName="ECSchemaDef" description="ECSchema" displayLabel="ECSchema" modifier="Sealed">
        <ECCustomAttributes>
            <ClassMap xmlns="ECDbMap.02.00.04">
                <MapStrategy>ExistingTable</MapStrategy>
                <TableName>ec_Schema</TableName>
            </ClassMap>
        </ECCustomAttributes>
        <ECProperty propertyName="Name" typeName="string"/>
        <ECProperty propertyName="DisplayLabel" typeName="string"/>
        <ECProperty propertyName="Description" typeName="string"/>
        <ECProperty propertyName="Alias" typeName="string"/>
        <ECProperty propertyName="VersionMajor" typeName="int">
            <ECCustomAttributes>
                <PropertyMap xmlns="ECDbMap.02.00.04">
                    <ColumnName>VersionDigit1</ColumnName>
                </PropertyMap>
            </ECCustomAttributes>
        </ECProperty>
        <ECProperty propertyName="VersionWrite" typeName="int">
            <ECCustomAttributes>
                <PropertyMap xmlns="ECDbMap.02.00.04">
                    <ColumnName>VersionDigit2</ColumnName>
                </PropertyMap>
            </ECCustomAttributes>
        </ECProperty>
        <ECProperty propertyName="VersionMinor" typeName="int">
            <ECCustomAttributes>
                <PropertyMap xmlns="ECDbMap.02.00.04">
                    <ColumnName>VersionDigit3</ColumnName>
                </PropertyMap>
            </ECCustomAttributes>
        </ECProperty>
        <ECProperty propertyName="OriginalECXmlVersionMajor" typeName="int"/>
        <ECProperty propertyName="OriginalECXmlVersionMinor" typeName="int"/>
    </ECEntityClass>
    <ECEntityClass typeName="ECClassDef" description="ECClass" displayLabel="ECClass" modifier="Sealed">
        <ECCustomAttributes>
            <ClassMap xmlns="ECDbMap.02.00.04">
                <MapStrategy>ExistingTable</MapStrategy>
                <TableName>ec_Class</TableName>
            </ClassMap>
        </ECCustomAttributes>
        <ECNavigationProperty propertyName="Schema" relationshipName="SchemaOwnsClasses" direction="backward"/>
        <ECProperty propertyName="Name" typeName="string"/>
        <ECProperty propertyName="DisplayLabel" typeName="string"/>
        <ECProperty propertyName="Description" typeName="string"/>
        <ECProperty propertyName="Type" typeName="ECClassType"/>
        <ECProperty propertyName="Modifier" typeName="ECClassModifier"/>
        <ECProperty propertyName="CustomAttributeContainerType" typeName="ECCustomAttributeContainerType" description="ECClassType::CustomAttribute: Specifies on which containers the custom attribute ECClass can be applied to."/>
        <ECProperty propertyName="RelationshipStrength" typeName="ECRelationshipStrength" description="Applies to ECClassType::Relationship only."/>
        <ECProperty propertyName="RelationshipStrengthDirection" typeName="ECRelationshipDirection" description="Applies to ECClassType::Relationship only."/>
    </ECEntityClass>
    <ECStructClass typeName="ECEnumeratorDef" modifier="Sealed">
        <ECProperty propertyName="Name" typeName="string"/>
        <ECProperty propertyName="DisplayLabel" typeName="string"/>
        <ECProperty propertyName="Description" typeName="string"/>
        <ECProperty propertyName="IntValue" typeName="int"/>
        <ECProperty propertyName="StringValue" typeName="string"/>
    </ECStructClass>
    <ECEntityClass typeName="ECEnumerationDef" description="ECEnumeration" displayLabel="ECEnumeration" modifier="Sealed">
        <ECCustomAttributes>
            <ClassMap xmlns="ECDbMap.02.00.04">
                <MapStrategy>ExistingTable</MapStrategy>
                <TableName>ec_Enumeration</TableName>
            </ClassMap>
        </ECCustomAttributes>
        <ECNavigationProperty propertyName="Schema" relationshipName="SchemaOwnsEnumerations" direction="backward"/>
        <ECProperty propertyName="Name" typeName="string"/>
        <ECProperty propertyName="DisplayLabel" typeName="string"/>
        <ECProperty propertyName="Description" typeName="string"/>
        <ECProperty propertyName="Type" typeName="PrimitiveType">
            <ECCustomAttributes>
                <PropertyMap xmlns="ECDbMap.02.00.04">
                    <ColumnName>UnderlyingPrimitiveType</ColumnName>
                </PropertyMap>
            </ECCustomAttributes>
        </ECProperty>
        <ECProperty propertyName="IsStrict" typeName="boolean"/>
        <ECStructArrayProperty propertyName="EnumValues" typeName="ECEnumeratorDef" minOccurs="1" maxOccurs="unbounded"/>
    </ECEntityClass>
    <ECEntityClass typeName="KindOfQuantityDef" description="KindOfQuantity" displayLabel="KindOfQuantity" modifier="Sealed">
        <ECCustomAttributes>
            <ClassMap xmlns="ECDbMap.02.00.04">
                <MapStrategy>ExistingTable</MapStrategy>
                <TableName>ec_KindOfQuantity</TableName>
            </ClassMap>
        </ECCustomAttributes>
        <ECNavigationProperty propertyName="Schema" relationshipName="SchemaOwnsKindOfQuantities" direction="backward"/>
        <ECProperty propertyName="Name" typeName="string"/>
        <ECProperty propertyName="DisplayLabel" typeName="string"/>
        <ECProperty propertyName="Description" typeName="string"/>
        <ECProperty propertyName="PersistenceUnit" typeName="string"/>
        <ECProperty propertyName="RelativeError" typeName="double"/>
        <ECArrayProperty propertyName="PresentationUnits" typeName="string"/>
    </ECEntityClass>
    <ECEntityClass typeName="UnitDef" description="Unit" displayLabel="Unit" modifier="Sealed">
        <ECCustomAttributes>
            <ClassMap xmlns="ECDbMap.02.00.04">
                <MapStrategy>ExistingTable</MapStrategy>
                <TableName>ec_Unit</TableName>
            </ClassMap>
        </ECCustomAttributes>
        <ECNavigationProperty propertyName="Schema" relationshipName="SchemaOwnsUnits" direction="backward"/>
        <ECProperty propertyName="Name" typeName="string"/>
        <ECProperty propertyName="DisplayLabel" typeName="string"/>
        <ECProperty propertyName="Description" typeName="string"/>
        <ECNavigationProperty propertyName="UnitSystem" relationshipName="UnitSystemHasUnits" direction="backward"/>
        <ECNavigationProperty propertyName="Phenomenon" relationshipName="PhenomenonOwnsUnits" direction="backward"/>
        <ECProperty propertyName="Definition" typeName="string"/>
        <ECProperty propertyName="Numerator" typeName="double"/>
        <ECProperty propertyName="Denominator" typeName="double"/>
        <ECProperty propertyName="Offset" typeName="double"/>
        <ECProperty propertyName="IsConstant" typeName="boolean"/>
        <ECNavigationProperty propertyName="InvertingUnit" description="If this property is set, this UnitDef is an inverted unit. It inverts the unit specified by this property." relationshipName="UnitHasInvertedUnit" direction="backward"/>
    </ECEntityClass>
    <ECEntityClass typeName="UnitSystemDef" description="UnitSystem" displayLabel="UnitSystem" modifier="Sealed">
        <ECCustomAttributes>
            <ClassMap xmlns="ECDbMap.02.00.04">
                <MapStrategy>ExistingTable</MapStrategy>
                <TableName>ec_UnitSystem</TableName>
            </ClassMap>
        </ECCustomAttributes>
        <ECNavigationProperty propertyName="Schema" relationshipName="SchemaOwnsUnitSystems" direction="backward"/>
        <ECProperty propertyName="Name" typeName="string"/>
        <ECProperty propertyName="DisplayLabel" typeName="string"/>
        <ECProperty propertyName="Description" typeName="string"/>
    </ECEntityClass>
    <ECEntityClass typeName="PhenomenonDef" description="Phenomenon" displayLabel="Phenomenon" modifier="Sealed">
        <ECCustomAttributes>
            <ClassMap xmlns="ECDbMap.02.00.04">
                <MapStrategy>ExistingTable</MapStrategy>
                <TableName>ec_Phenomenon</TableName>
            </ClassMap>
        </ECCustomAttributes>
        <ECNavigationProperty propertyName="Schema" relationshipName="SchemaOwnsPhenomena" direction="backward"/>
        <ECProperty propertyName="Name" typeName="string"/>
        <ECProperty propertyName="DisplayLabel" typeName="string"/>
        <ECProperty propertyName="Description" typeName="string"/>
        <ECProperty propertyName="Definition" typeName="string"/>
    </ECEntityClass>
    <ECEntityClass typeName="FormatDef" description="Format" displayLabel="Format" modifier="Sealed">
        <ECCustomAttributes>
            <ClassMap xmlns="ECDbMap.02.00.04">
                <MapStrategy>ExistingTable</MapStrategy>
                <TableName>ec_Format</TableName>
            </ClassMap>
        </ECCustomAttributes>
        <ECNavigationProperty propertyName="Schema" relationshipName="SchemaOwnsFormats" direction="backward"/>
        <ECProperty propertyName="Name" typeName="string"/>
        <ECProperty propertyName="DisplayLabel" typeName="string"/>
        <ECProperty propertyName="Description" typeName="string"/>
        <ECProperty propertyName="NumericSpec" typeName="string" extendedTypeName="JSON"/>
        <ECProperty propertyName="CompositeSpec" typeName="string" description="CompositeSpec without units. Composite units are held by FormatCompositeUnitDef" extendedTypeName="JSON"/>
    </ECEntityClass>
    <ECEntityClass typeName="FormatCompositeUnitDef" description="FormatCompositeUnit" displayLabel="FormatCompositeUnit" modifier="Sealed">
        <ECCustomAttributes>
            <ClassMap xmlns="ECDbMap.02.00.04">
                <MapStrategy>ExistingTable</MapStrategy>
                <TableName>ec_FormatCompositeUnit</TableName>
            </ClassMap>
        </ECCustomAttributes>
        <ECNavigationProperty propertyName="Format" relationshipName="FormatOwnsCompositeUnits" direction="backward"/>
        <ECProperty propertyName="Label" typeName="string"/>
        <ECNavigationProperty propertyName="Unit" relationshipName="CompositeUnitRefersToUnit" direction="forward"/>
        <ECProperty propertyName="Ordinal" typeName="int" description="Position of the Composite Unit in its Format"/>
    </ECEntityClass>
    <ECEntityClass typeName="PropertyCategoryDef" description="PropertyCategory" displayLabel="PropertyCategory" modifier="Sealed">
        <ECCustomAttributes>
            <ClassMap xmlns="ECDbMap.02.00.04">
                <MapStrategy>ExistingTable</MapStrategy>
                <TableName>ec_PropertyCategory</TableName>
            </ClassMap>
        </ECCustomAttributes>
        <ECNavigationProperty propertyName="Schema" relationshipName="SchemaOwnsPropertyCategories" direction="backward"/>
        <ECProperty propertyName="Name" typeName="string"/>
        <ECProperty propertyName="DisplayLabel" typeName="string"/>
        <ECProperty propertyName="Description" typeName="string"/>
        <ECProperty propertyName="Priority" typeName="int"/>
    </ECEntityClass>
    <ECEntityClass typeName="ECPropertyDef" description="ECProperty" displayLabel="ECProperty" modifier="Sealed">
        <ECCustomAttributes>
            <ClassMap xmlns="ECDbMap.02.00.04">
                <MapStrategy>ExistingTable</MapStrategy>
                <TableName>ec_Property</TableName>
            </ClassMap>
        </ECCustomAttributes>
        <ECNavigationProperty propertyName="Class" relationshipName="ClassOwnsLocalProperties" direction="backward"/>
        <ECProperty propertyName="Name" typeName="string"/>
        <ECProperty propertyName="DisplayLabel" typeName="string"/>
        <ECProperty propertyName="Description" typeName="string"/>
        <ECProperty propertyName="IsReadonly" typeName="boolean"/>
        <ECProperty propertyName="Priority" typeName="int"/>
        <ECProperty propertyName="Ordinal" typeName="int" description="Position of the ECProperty in its ECClass"/>
        <ECProperty propertyName="Kind" typeName="ECPropertyKind"/>
        <ECProperty propertyName="PrimitiveType" typeName="PrimitiveType" description="ECPropertyKind::Primitive: data type. ECPropertyKind::PrimitiveArray: data type of array elements."/>
        <ECProperty propertyName="PrimitiveTypeMinLength" typeName="int" description="Minimum length of strings or blobs."/>
        <ECProperty propertyName="PrimitiveTypeMaxLength" typeName="int" description="Maximum length of strings or blobs."/>
        <ECProperty propertyName="PrimitiveTypeMinValue" typeName="double" description="Minimum value of numeric primitives."/>
        <ECProperty propertyName="PrimitiveTypeMaxValue" typeName="double" description="Maximum value of numeric primitives."/>
        <ECNavigationProperty propertyName="Enumeration" description="ECPropertyKind::Primitive: Id of this property's ECEnumerationDef." relationshipName="PropertyHasEnumeration" direction="forward"/>
        <ECProperty propertyName="ExtendedTypeName" typeName="string" description="ECPropertyKind::Primitive or ECPropertyKind::PrimitiveArray: Extended type name further describing PrimitiveType."/>
        <ECNavigationProperty propertyName="StructClass" description="ECPropertyKind::Struct: ECClassId of property's struct type. ECPropertyKind::StructArray: ECClassId of array element struct type." relationshipName="PropertyHasStructType" direction="forward"/>
        <ECNavigationProperty propertyName="KindOfQuantity" description="ECPropertyKind::Primitive or ECPropertyKind::PrimitiveArray: Id of this property's KindOfQuantityDef." relationshipName="PropertyHasKindOfQuantity" direction="forward"/>
        <ECNavigationProperty propertyName="Category" description="Id of this property's PropertyCategoryDef." relationshipName="PropertyHasCategory" direction="forward"/>
        <ECProperty propertyName="ArrayMinOccurs" typeName="int" description="ECPropertyKind::PrimitiveArray or ECPropertyKind::StructArray"/>
        <ECProperty propertyName="ArrayMaxOccurs" typeName="int" description="ECPropertyKind::PrimitiveArray or ECPropertyKind::StructArray"/>
        <ECNavigationProperty propertyName="NavigationRelationshipClass" description="ECPropertyKind::Navigation: ECClassId of property's relationship class." relationshipName="PropertyHasNavigationRelationshipClassId" direction="forward"/>
        <ECProperty propertyName="NavigationDirection" typeName="ECRelationshipDirection" description="ECPropertyKind::Navigation: Direction to follow the relationship defined in NonPrimitiveTypeClassId."/>
    </ECEntityClass>
    <ECEntityClass typeName="ECRelationshipConstraintDef" modifier="Sealed">
        <ECCustomAttributes>
            <ClassMap xmlns="ECDbMap.02.00.04">
                <MapStrategy>ExistingTable</MapStrategy>
                <TableName>ec_RelationshipConstraint</TableName>
            </ClassMap>
        </ECCustomAttributes>
        <ECNavigationProperty propertyName="RelationshipClass" relationshipName="RelationshipHasConstraints" direction="backward"/>
        <ECProperty propertyName="RelationshipEnd" typeName="ECRelationshipEnd"/>
        <ECProperty propertyName="MultiplicityLowerLimit" typeName="int"/>
        <ECProperty propertyName="MultiplicityUpperLimit" typeName="int"/>
        <ECProperty propertyName="IsPolymorphic" typeName="boolean"/>
        <ECProperty propertyName="RoleLabel" typeName="string"/>
        <ECNavigationProperty propertyName="AbstractConstraintClass" description="ECClassId of base class for constraint classes of this constraint" relationshipName="RelationshipConstraintHasAbstractConstraintClass" direction="forward"/>
    </ECEntityClass>
    <ECRelationshipClass typeName="SchemaOwnsClasses" modifier="Sealed" strength="embedding">
        <Source multiplicity="(1..1)" roleLabel="contains" polymorphic="false">
            <Class class="ECSchemaDef"/>
        </Source>
        <Target multiplicity="(0..*)" roleLabel="is defined in" polymorphic="false">
            <Class class="ECClassDef"/>
        </Target>
    </ECRelationshipClass>
    <ECRelationshipClass typeName="SchemaHasSchemaReferences" modifier="Sealed" strength="referencing">
        <ECCustomAttributes>
            <ClassMap xmlns="ECDbMap.02.00.04">
                <MapStrategy>ExistingTable</MapStrategy>
                <TableName>ec_SchemaReference</TableName>
            </ClassMap>
            <LinkTableRelationshipMap xmlns="ECDbMap.02.00.04">
                <SourceECInstanceIdColumn>SchemaId</SourceECInstanceIdColumn>
                <TargetECInstanceIdColumn>ReferencedSchemaId</TargetECInstanceIdColumn>
            </LinkTableRelationshipMap>
        </ECCustomAttributes>
        <Source multiplicity="(0..*)" roleLabel="references" polymorphic="false">
            <Class class="ECSchemaDef"/>
        </Source>
        <Target multiplicity="(0..*)" roleLabel="is referenced by" polymorphic="false">
            <Class class="ECSchemaDef"/>
        </Target>
    </ECRelationshipClass>
    <ECRelationshipClass typeName="ClassOwnsLocalProperties" modifier="Sealed" strength="embedding">
        <Source multiplicity="(1..1)" roleLabel="locally defines" polymorphic="false">
            <Class class="ECClassDef"/>
        </Source>
        <Target multiplicity="(0..*)" roleLabel="is defined in" polymorphic="false">
            <Class class="ECPropertyDef"/>
        </Target>
    </ECRelationshipClass>
    <ECRelationshipClass typeName="ClassHasBaseClasses" modifier="Sealed" strength="referencing">
        <ECCustomAttributes>
            <ClassMap xmlns="ECDbMap.02.00.04">
                <MapStrategy>ExistingTable</MapStrategy>
                <TableName>ec_ClassHasBaseClasses</TableName>
            </ClassMap>
            <LinkTableRelationshipMap xmlns="ECDbMap.02.00.04">
                <SourceECInstanceIdColumn>ClassId</SourceECInstanceIdColumn>
                <TargetECInstanceIdColumn>BaseClassId</TargetECInstanceIdColumn>
            </LinkTableRelationshipMap>
        </ECCustomAttributes>
        <ECProperty propertyName="Ordinal" typeName="int"/>
        <Source multiplicity="(0..*)" roleLabel="is subclass of" polymorphic="false">
            <Class class="ECClassDef"/>
        </Source>
        <Target multiplicity="(0..*)" roleLabel="is base class of" polymorphic="false">
            <Class class="ECClassDef"/>
        </Target>
    </ECRelationshipClass>
    <ECRelationshipClass typeName="ClassHasAllBaseClasses" strength="referencing" modifier="Sealed" description="Relates a given ECClassId (Source) to all its base classes (recursively) (Target). For optimization reasons this ECRelationshipClass also holds a row for each ECClass that points to itself. Base class id order: class itself, then base classes in breadth first manner.">
        <ECCustomAttributes>
            <ClassMap xmlns="ECDbMap.02.00.04">
                <MapStrategy>ExistingTable</MapStrategy>
                <TableName>ec_cache_ClassHierarchy</TableName>
            </ClassMap>
            <LinkTableRelationshipMap xmlns="ECDbMap.02.00.04">
                <SourceECInstanceIdColumn>ClassId</SourceECInstanceIdColumn>
                <TargetECInstanceIdColumn>BaseClassId</TargetECInstanceIdColumn>
            </LinkTableRelationshipMap>
        </ECCustomAttributes>
        <Source multiplicity="(0..*)" roleLabel="is a" polymorphic="false">
            <Class class="ECClassDef"/>
        </Source>
        <Target multiplicity="(0..*)" roleLabel="is ancestor of" polymorphic="false">
            <Class class="ECClassDef"/>
        </Target>
    </ECRelationshipClass>   
    <ECRelationshipClass typeName="SchemaOwnsEnumerations" modifier="Sealed" strength="embedding">
        <Source multiplicity="(1..1)" roleLabel="contains" polymorphic="false">
            <Class class="ECSchemaDef"/>
        </Source>
        <Target multiplicity="(0..*)" roleLabel="is defined in" polymorphic="false">
            <Class class="ECEnumerationDef"/>
        </Target>
    </ECRelationshipClass>
    <ECRelationshipClass typeName="SchemaOwnsKindOfQuantities" modifier="Sealed" strength="embedding">
        <Source multiplicity="(1..1)" roleLabel="contains" polymorphic="false">
            <Class class="ECSchemaDef"/>
        </Source>
        <Target multiplicity="(0..*)" roleLabel="is defined in" polymorphic="false">
            <Class class="KindOfQuantityDef"/>
        </Target>
    </ECRelationshipClass>
    <ECRelationshipClass typeName="SchemaOwnsUnitSystems" modifier="Sealed" strength="embedding">
        <Source multiplicity="(1..1)" roleLabel="contains" polymorphic="false">
            <Class class="ECSchemaDef"/>
        </Source>
        <Target multiplicity="(0..*)" roleLabel="is defined in" polymorphic="false">
            <Class class="UnitSystemDef"/>
        </Target>
    </ECRelationshipClass>
    <ECRelationshipClass typeName="SchemaOwnsPhenomena" modifier="Sealed" strength="embedding">
        <Source multiplicity="(1..1)" roleLabel="contains" polymorphic="false">
            <Class class="ECSchemaDef"/>
        </Source>
        <Target multiplicity="(0..*)" roleLabel="is defined in" polymorphic="false">
            <Class class="PhenomenonDef"/>
        </Target>
    </ECRelationshipClass>
    <ECRelationshipClass typeName="SchemaOwnsUnits" modifier="Sealed" strength="embedding">
        <Source multiplicity="(1..1)" roleLabel="contains" polymorphic="false">
            <Class class="ECSchemaDef"/>
        </Source>
        <Target multiplicity="(0..*)" roleLabel="is defined in" polymorphic="false">
            <Class class="UnitDef"/>
        </Target>
    </ECRelationshipClass>
    <ECRelationshipClass typeName="SchemaOwnsFormats" modifier="Sealed" strength="embedding">
        <Source multiplicity="(1..1)" roleLabel="contains" polymorphic="false">
            <Class class="ECSchemaDef"/>
        </Source>
        <Target multiplicity="(0..*)" roleLabel="is defined in" polymorphic="false">
            <Class class="FormatDef"/>
        </Target>
    </ECRelationshipClass>
    <ECRelationshipClass typeName="FormatOwnsCompositeUnits" modifier="Sealed" strength="embedding">
        <Source multiplicity="(1..1)" roleLabel="contains" polymorphic="false">
            <Class class="FormatDef"/>
        </Source>
        <Target multiplicity="(0..*)" roleLabel="is defined in" polymorphic="false">
            <Class class="FormatCompositeUnitDef"/>
        </Target>
    </ECRelationshipClass>
    <ECRelationshipClass typeName="CompositeUnitRefersToUnit" modifier="Sealed" strength="referencing">
        <Source multiplicity="(0..*)" roleLabel="refers to" polymorphic="false">
            <Class class="FormatCompositeUnitDef"/>
        </Source>
        <Target multiplicity="(0..1)" roleLabel="is referred to by" polymorphic="false">
            <Class class="UnitDef"/>
        </Target>
    </ECRelationshipClass>
    <ECRelationshipClass typeName="SchemaOwnsPropertyCategories" modifier="Sealed" strength="embedding">
        <Source multiplicity="(1..1)" roleLabel="contains" polymorphic="false">
            <Class class="ECSchemaDef"/>
        </Source>
        <Target multiplicity="(0..*)" roleLabel="is defined in" polymorphic="false">
            <Class class="PropertyCategoryDef"/>
        </Target>
    </ECRelationshipClass>
    <ECRelationshipClass typeName="PhenomenonOwnsUnits" modifier="Sealed" strength="embedding">
        <Source multiplicity="(1..1)" roleLabel="has" polymorphic="false">
            <Class class="PhenomenonDef"/>
        </Source>
        <Target multiplicity="(0..*)" roleLabel="is of" polymorphic="false">
            <Class class="UnitDef"/>
        </Target>
    </ECRelationshipClass>
    <ECRelationshipClass typeName="UnitSystemHasUnits" modifier="Sealed" strength="referencing">
        <Source multiplicity="(0..1)" roleLabel="has" polymorphic="false">
            <Class class="UnitSystemDef"/>
        </Source>
        <Target multiplicity="(0..*)" roleLabel="is defined in" polymorphic="false">
            <Class class="UnitDef"/>
        </Target>
    </ECRelationshipClass>
    <ECRelationshipClass typeName="UnitHasInvertedUnit" modifier="Sealed" strength="referencing">
        <Source multiplicity="(0..1)" roleLabel="is inverted by" polymorphic="false">
            <Class class="UnitDef"/>
        </Source>
        <Target multiplicity="(0..1)" roleLabel="inverts" polymorphic="false">
            <Class class="UnitDef"/>
        </Target>
    </ECRelationshipClass>
    <ECRelationshipClass typeName="PropertyHasEnumeration" description="ECPropertyKind::Enumeration: relates the property to its ECEnumeration." modifier="Sealed" strength="referencing">
        <Source multiplicity="(0..*)" roleLabel="is of type" polymorphic="false">
            <Class class="ECPropertyDef"/>
        </Source>
        <Target multiplicity="(0..1)" roleLabel="is type of" polymorphic="false">
            <Class class="ECEnumerationDef"/>
        </Target>
    </ECRelationshipClass>
    <ECRelationshipClass typeName="PropertyHasStructType" description="ECPropertyKind::Struct: relates the struct property to its struct ECClass. ECPropertyKind::StructArray: relates the struct array property to its array element type." modifier="Sealed" strength="referencing">
        <Source multiplicity="(0..*)" roleLabel="is of type" polymorphic="false">
            <Class class="ECPropertyDef"/>
        </Source>
        <Target multiplicity="(0..1)" roleLabel="is type of" polymorphic="false">
            <Class class="ECClassDef"/>
        </Target>
    </ECRelationshipClass>
    <ECRelationshipClass typeName="PropertyHasNavigationRelationshipClassId" description="ECPropertyKind::Navigation: relates the navigation property to its backing RelationshipECClass." modifier="Sealed" strength="referencing">
        <Source multiplicity="(0..*)" roleLabel="is backed by" polymorphic="false">
            <Class class="ECPropertyDef"/>
        </Source>
        <Target multiplicity="(0..1)" roleLabel="is ECRelationshipClass of" polymorphic="false">
            <Class class="ECClassDef"/>
        </Target>
    </ECRelationshipClass>
    <ECRelationshipClass typeName="PropertyHasKindOfQuantity" description="ECPropertyKind::Primitive or ECPropertyKind::PrimitiveArray: relates the property to its KindOfQuantity." modifier="Sealed" strength="referencing">
        <Source multiplicity="(0..*)" roleLabel="has" polymorphic="false">
            <Class class="ECPropertyDef"/>
        </Source>
        <Target multiplicity="(0..1)" roleLabel="is used by" polymorphic="false">
            <Class class="KindOfQuantityDef"/>
        </Target>
    </ECRelationshipClass>
    <ECRelationshipClass typeName="PropertyHasCategory" description="Relates the property to its PropertyCategory." modifier="Sealed" strength="referencing">
        <Source multiplicity="(0..*)" roleLabel="is in" polymorphic="false">
            <Class class="ECPropertyDef"/>
        </Source>
        <Target multiplicity="(0..1)" roleLabel="is used by" polymorphic="false">
            <Class class="PropertyCategoryDef"/>
        </Target>
    </ECRelationshipClass>
    <ECRelationshipClass typeName="RelationshipHasConstraints" modifier="Sealed" strength="referencing">
        <Source multiplicity="(1..1)" roleLabel="defines" polymorphic="false">
            <Class class="ECClassDef"/>
        </Source>
        <Target multiplicity="(2..2)" roleLabel="is defined by" polymorphic="false">
            <Class class="ECRelationshipConstraintDef"/>
        </Target>
    </ECRelationshipClass>
    <ECRelationshipClass typeName="RelationshipConstraintHasAbstractConstraintClass" modifier="Sealed" strength="referencing">
        <Source multiplicity="(0..*)" roleLabel="defines" polymorphic="false">
            <Class class="ECRelationshipConstraintDef"/>
        </Source>
        <Target multiplicity="(0..1)" roleLabel="is abstract constraint class of" polymorphic="false">
            <Class class="ECClassDef"/>
        </Target>
    </ECRelationshipClass>
    <ECRelationshipClass typeName="RelationshipConstraintHasClasses" modifier="Sealed" strength="referencing">
        <ECCustomAttributes>
            <ClassMap xmlns="ECDbMap.02.00.04">
                <MapStrategy>ExistingTable</MapStrategy>
                <TableName>ec_RelationshipConstraintClass</TableName>
            </ClassMap>
            <LinkTableRelationshipMap xmlns="ECDbMap.02.00.04">
                <SourceECInstanceIdColumn>ConstraintId</SourceECInstanceIdColumn>
                <TargetECInstanceIdColumn>ClassId</TargetECInstanceIdColumn>
            </LinkTableRelationshipMap>
        </ECCustomAttributes>
        <Source multiplicity="(0..*)" roleLabel="contains" polymorphic="false">
            <Class class="ECRelationshipConstraintDef"/>
        </Source>
        <Target multiplicity="(0..*)" roleLabel="is constraint class of" polymorphic="false">
            <Class class="ECClassDef"/>
        </Target>
    </ECRelationshipClass>
    <!-- ECCustomAttributeContainerType can be OR'ed together. That cannot be expressed in the ECEnumerations
         directly though. -->
    <ECEnumeration typeName="ECCustomAttributeContainerType" backingTypeName="int" isStrict="true">
        <ECEnumerator name="Schema" value="1" displayLabel="Schema" />
        <ECEnumerator name="EntityClass" value="2" displayLabel="EntityClass"/>
        <ECEnumerator name="CustomAttributeClass" value="4" displayLabel="CustomAttributeClass"/>
        <ECEnumerator name="StructClass" value="8" displayLabel="StructClass"/>
        <ECEnumerator name="RelationshipClass" value="16" displayLabel="RelationshipClass"/>
        <ECEnumerator name="AnyClass" value="30" displayLabel="AnyClass"/>
        <ECEnumerator name="PrimitiveProperty" value="32" displayLabel="PrimitiveProperty"/>
        <ECEnumerator name="StructProperty" value="64" displayLabel="StructProperty"/>
        <ECEnumerator name="PrimitiveArrayProperty" value="128" displayLabel="PrimitiveArrayProperty"/>
        <ECEnumerator name="StructArrayProperty" value="256" displayLabel="StructArrayProperty"/>
        <ECEnumerator name="NavigationProperty" value="512" displayLabel="NavigationProperty"/>
        <ECEnumerator name="AnyProperty" value="992" displayLabel="AnyProperty"/>
        <ECEnumerator name="SourceRelationshipConstraint" value="1024" displayLabel="SourceRelationshipConstraint"/>
        <ECEnumerator name="TargetRelationshipConstraint" value="2048" displayLabel="TargetRelationshipConstraint"/>
        <ECEnumerator name="AnyRelationshipConstraint" value="3072" displayLabel="AnyRelationshipConstraint"/>
        <ECEnumerator name="Any" value="4095" displayLabel="Any"/>
    </ECEnumeration>
    <ECEnumeration typeName="ECClassModifier" backingTypeName="int" isStrict="true">
        <ECEnumerator name="None" value="0" displayLabel="None" />
        <ECEnumerator name="Abstract" value="1" displayLabel="Abstract" />
        <ECEnumerator name="Sealed" value="2" displayLabel="Sealed" />
    </ECEnumeration>
    <ECEnumeration typeName="ECRelationshipEnd" backingTypeName="int" isStrict="true">
        <ECEnumerator name="Source" value="0" displayLabel="Source" />
        <ECEnumerator name="Target" value="1" displayLabel="Target" />
    </ECEnumeration>
    <ECEnumeration typeName="ECClassType" backingTypeName="int" isStrict="true">
        <ECEnumerator name="Entity" value="0" displayLabel="Entity" />
        <ECEnumerator name="Relationship" value="1" displayLabel="Relationship" />
        <ECEnumerator name="Struct" value="2" displayLabel="Struct" />
        <ECEnumerator name="CustomAttribute" value="3" displayLabel="CustomAttribute" />
    </ECEnumeration>
    <ECEnumeration typeName="ECPropertyKind" backingTypeName="int" isStrict="true">
        <ECEnumerator name="Primitive" value="0" displayLabel="Primitive" />
        <ECEnumerator name="Struct" value="1" displayLabel="Struct" />
        <ECEnumerator name="PrimitiveArray" value="2" displayLabel="PrimitiveArray" />
        <ECEnumerator name="StructArray" value="3" displayLabel="StructArray" />
        <ECEnumerator name="Navigation" value="4" displayLabel="Navigation" />
    </ECEnumeration>
    <ECEnumeration typeName="ECRelationshipDirection" backingTypeName="int" isStrict="true">
        <ECEnumerator name="Forward" value="1" displayLabel="Forward" />
        <ECEnumerator name="Backward" value="2" displayLabel="Backward" />
    </ECEnumeration>
    <ECEnumeration typeName="ECRelationshipStrength" backingTypeName="int" isStrict="true">
        <ECEnumerator name="Referencing" value="0" displayLabel="Referencing" />
        <ECEnumerator name="Holding" value="1" displayLabel="Holding" />
        <ECEnumerator name="Embedding" value="2" displayLabel="Embedding" />
    </ECEnumeration>
    <ECEnumeration typeName="PrimitiveType" backingTypeName="int" isStrict="true">
        <ECEnumerator name="Binary" value="257" displayLabel="Binary" />
        <ECEnumerator name="Boolean" value="513" displayLabel="Boolean" />
        <ECEnumerator name="DateTime" value="769" displayLabel="DateTime" />
        <ECEnumerator name="Double" value="1025" displayLabel="Double" />
        <ECEnumerator name="Integer" value="1281" displayLabel="Integer" />
        <ECEnumerator name="Long" value="1537" displayLabel="Long" />
        <ECEnumerator name="Point2d" value="1793" displayLabel="Point2d" />
        <ECEnumerator name="Point3d" value="2049" displayLabel="Point3d" />
        <ECEnumerator name="String" value="2305" displayLabel="String" />
        <ECEnumerator name="IGeometry" value="2561" displayLabel="IGeometry" />
    </ECEnumeration>
    <ECEnumeration typeName="CAContainerType" backingTypeName="int" isStrict="true">
        <ECEnumerator name="Schema" value="1" displayLabel="Schema" />
        <ECEnumerator name="Class" value="30" displayLabel="Class" />
        <ECEnumerator name="Property" value="992" displayLabel="Property" />
    </ECEnumeration>

    <!-- Flat list of Custom Attributes without relationships to their container -->
    <ECEntityClass typeName="CustomAttribute" displayLabel="CustomAttribute" description="Returns all existing custom attributes, there are specialized versions of this for Property, Class and Schema."  modifier="Sealed">
        <ECCustomAttributes>
            <ClassMap xmlns="ECDbMap.02.00.04">
                <MapStrategy>ExistingTable</MapStrategy>
                <TableName>ec_CustomAttribute</TableName>
            </ClassMap>
        </ECCustomAttributes>
        <ECProperty propertyName="ContainerId"  typeName="long" extendedTypeName="Id" />
        <ECProperty propertyName="ContainerType"  typeName="CAContainerType"/>
        <ECProperty propertyName="Ordinal"  typeName="int"/>
        <ECProperty propertyName="Instance"  typeName="string" extendedTypeName="Xml"/>
        <ECNavigationProperty propertyName="Class" relationshipName="CustomAttributeClassHasInstance" direction="backward"/>
    </ECEntityClass>
    <ECRelationshipClass typeName="CustomAttributeClassHasInstance" modifier="Sealed" strength="referencing">
        <Source multiplicity="(1..1)" roleLabel="has instance" polymorphic="false">
            <Class class="ECClassDef"/>
        </Source>
        <Target multiplicity="(0..*)" roleLabel="is instance of" polymorphic="false">
            <Class class="CustomAttribute"/>
        </Target>
    </ECRelationshipClass>

    <!-- Concrete Custom Attribute instances for property/class/schema -->
    <ECEntityClass typeName="PropertyCustomAttribute" modifier="Abstract">
        <ECCustomAttributes>
            <QueryView xmlns="ECDbMap.02.00.04">
                <Query>
                    SELECT
                        [ca].[ECInstanceId],
                        ec_classid('ECDbMeta', 'PropertyCustomAttribute') [ECClassId],
                        NAVIGATION_VALUE(meta.PropertyCustomAttribute.Property, [ca].[ContainerId]),
                        NAVIGATION_VALUE(meta.PropertyCustomAttribute.CustomAttributeClass, [ca].[Class].[Id]),
                        XmlCAToJson([ca].[Class].[Id], [ca].[Instance]) [Instance]
                    FROM [meta].[CustomAttribute] [ca]
                    WHERE [ca].[ContainerType] = [meta].[CAContainerType].[Property]
                    ORDER BY [ca].[Ordinal]
                </Query>
            </QueryView>
        </ECCustomAttributes>
        <ECNavigationProperty propertyName="Property" relationshipName="PropertyHasCustomAttribute" direction="backward"/>
        <ECNavigationProperty propertyName="CustomAttributeClass" relationshipName="CustomAttributeClassHasInstanceOnProperty" direction="backward"/>
        <ECProperty propertyName="Instance"  typeName="string" extendedTypeName="Json" />
    </ECEntityClass>
    <ECRelationshipClass typeName="PropertyHasCustomAttribute" modifier="Abstract" strength="referencing">
        <ECCustomAttributes>
            <ForeignKeyView xmlns="ECDbMap.02.00.04" />
        </ECCustomAttributes>
        <Source multiplicity="(1..1)" roleLabel="has custom attribute" polymorphic="false">
            <Class class="ECPropertyDef"/>
        </Source>
        <Target multiplicity="(0..*)" roleLabel="is set on" polymorphic="false">
            <Class class="PropertyCustomAttribute"/>
        </Target>
    </ECRelationshipClass>
    <ECRelationshipClass typeName="CustomAttributeClassHasInstanceOnProperty" modifier="Abstract" strength="referencing">
        <ECCustomAttributes>
            <ForeignKeyView xmlns="ECDbMap.02.00.04" />
        </ECCustomAttributes>
        <Source multiplicity="(1..1)" roleLabel="has instance on" polymorphic="false">
            <Class class="ECClassDef"/>
        </Source>
        <Target multiplicity="(0..*)" roleLabel="is instance of" polymorphic="false">
            <Class class="PropertyCustomAttribute"/>
        </Target>
    </ECRelationshipClass>

    <ECEntityClass typeName="ClassCustomAttribute" modifier="Abstract">
        <ECCustomAttributes>
            <QueryView xmlns="ECDbMap.02.00.04">
                <Query>
                    SELECT
                        [ca].[ECInstanceId],
                        ec_classid('ECDbMeta', 'ClassCustomAttribute') [ECClassId],
                        NAVIGATION_VALUE(meta.ClassCustomAttribute.Class, [ca].[ContainerId]),
                        NAVIGATION_VALUE(meta.ClassCustomAttribute.CustomAttributeClass, [ca].[Class].[Id]),
                        XmlCAToJson([ca].[Class].[Id], [ca].[Instance]) [Instance]
                    FROM [meta].[CustomAttribute] [ca]
                    WHERE [ca].[ContainerType] = [meta].[CAContainerType].[Class]
                    ORDER BY [ca].[Ordinal]
                </Query>
            </QueryView>
        </ECCustomAttributes>
        <ECNavigationProperty propertyName="Class" relationshipName="ClassHasCustomAttribute" direction="backward"/>
        <ECNavigationProperty propertyName="CustomAttributeClass" relationshipName="CustomAttributeClassHasInstanceOnClass" direction="backward"/>
        <ECProperty propertyName="Instance"  typeName="string" extendedTypeName="Json" />
    </ECEntityClass>
    <ECRelationshipClass typeName="ClassHasCustomAttribute" modifier="Abstract" strength="referencing">
        <ECCustomAttributes>
            <ForeignKeyView xmlns="ECDbMap.02.00.04" />
        </ECCustomAttributes>
        <Source multiplicity="(1..1)" roleLabel="has custom attribute" polymorphic="false">
            <Class class="ECClassDef"/>
        </Source>
        <Target multiplicity="(0..*)" roleLabel="is set on" polymorphic="false">
            <Class class="ClassCustomAttribute"/>
        </Target>
    </ECRelationshipClass>
    <ECRelationshipClass typeName="CustomAttributeClassHasInstanceOnClass" modifier="Abstract" strength="referencing">
        <ECCustomAttributes>
            <ForeignKeyView xmlns="ECDbMap.02.00.04" />
        </ECCustomAttributes>
        <Source multiplicity="(1..1)" roleLabel="has instance on" polymorphic="false">
            <Class class="ECClassDef"/>
        </Source>
        <Target multiplicity="(0..*)" roleLabel="is instance of" polymorphic="false">
            <Class class="ClassCustomAttribute"/>
        </Target>
    </ECRelationshipClass>

    <ECEntityClass typeName="SchemaCustomAttribute" modifier="Abstract">
        <ECCustomAttributes>
            <QueryView xmlns="ECDbMap.02.00.04">
                <Query>
                    SELECT
                        [ca].[ECInstanceId],
                        ec_classid('ECDbMeta', 'SchemaCustomAttribute') [ECClassId],
                        NAVIGATION_VALUE(meta.SchemaCustomAttribute.Schema, [ca].[ContainerId]),
                        NAVIGATION_VALUE(meta.SchemaCustomAttribute.CustomAttributeClass, [ca].[Class].[Id]),
                        XmlCAToJson([ca].[Class].[Id], [ca].[Instance]) [Instance]
                    FROM [meta].[CustomAttribute] [ca]
                    WHERE [ca].[ContainerType] = [meta].[CAContainerType].[Schema]
                    ORDER BY [ca].[Ordinal]
                </Query>
            </QueryView>
        </ECCustomAttributes>
        <ECNavigationProperty propertyName="Schema" relationshipName="SchemaHasCustomAttribute" direction="backward"/>
        <ECNavigationProperty propertyName="CustomAttributeClass" relationshipName="CustomAttributeClassHasInstanceOnSchema" direction="backward"/>
        <ECProperty propertyName="Instance"  typeName="string" extendedTypeName="Json" />
    </ECEntityClass>
    <ECRelationshipClass typeName="SchemaHasCustomAttribute" modifier="Abstract" strength="referencing">
        <ECCustomAttributes>
            <ForeignKeyView xmlns="ECDbMap.02.00.04" />
        </ECCustomAttributes>
        <Source multiplicity="(1..1)" roleLabel="has custom attribute" polymorphic="false">
            <Class class="ECSchemaDef"/>
        </Source>
        <Target multiplicity="(0..*)" roleLabel="is set on" polymorphic="false">
            <Class class="SchemaCustomAttribute"/>
        </Target>
    </ECRelationshipClass>
    <ECRelationshipClass typeName="CustomAttributeClassHasInstanceOnSchema" modifier="Abstract" strength="referencing">
        <ECCustomAttributes>
            <ForeignKeyView xmlns="ECDbMap.02.00.04" />
        </ECCustomAttributes>
        <Source multiplicity="(1..1)" roleLabel="has instance on" polymorphic="false">
            <Class class="ECClassDef"/>
        </Source>
        <Target multiplicity="(0..*)" roleLabel="is instance of" polymorphic="false">
            <Class class="SchemaCustomAttribute"/>
        </Target>
    </ECRelationshipClass>
</ECSchema>
