/// <summary>
        /// Removes this instance from the parent it was attached to.
        /// Parent may be an Entity or ComplexObject
        /// </summary>
        internal void DetachFromParent()
        {
            // We will null out _parent and _parentPropertyName anyway, so if they are already null
            // it is an unexpected condition, but should not cause a failure in released code
            Debug.Assert(_parent != null, "Attempt to detach from a null _parent");
            Debug.Assert(_parentPropertyName != null, "Null _parentPropertyName on a non-null _parent");

            _parent             = null;
            _parentPropertyName = null;
        }
        private string _parentPropertyName;   // Property name for this type on the containing object

        /// <summary>
        /// Associate the ComplexType with an Entity or another ComplexObject
        /// Parent may be an Entity or ComplexObject
        /// </summary>
        /// <param name="parent">Object to be added to.</param>
        /// <param name="parentPropertyName">The property on the parent that reference the complex type.</param>
        internal void AttachToParent(
            StructuralObject parent,
            string parentPropertyName)
        {
            Debug.Assert(null != parent, "Attempt to attach to a null parent");
            Debug.Assert(null != parentPropertyName, "Must provide parentPropertyName in order to attach");

            if (_parent != null)
            {
                throw EntityUtil.ComplexObjectAlreadyAttachedToParent();
            }

            Debug.Assert(_parentPropertyName == null);

            _parent             = parent;
            _parentPropertyName = parentPropertyName;
        }