private CustomEntityType CheckTypeCompatibility(object entityObject)
        {
            Debug.Assert(null != entityObject);

            CustomEntityType entityType = MetadataWorkspace.GetEntityType(entityObject.GetType());

            if (!EntitySetType.BaseElementType.IsAssignableFrom(entityType))
            {
                throw new InvalidOperationException(String.Format(
                                                        "The base element type '{0}' of the entity set '{1}' is not compatible with " +
                                                        "the entity type '{2}' of the object '{3}'.",
                                                        EntitySetType.BaseElementType, EntitySetType.Name, entityType, entityObject
                                                        ));
            }
            return(entityType);
        }