protected virtual bool IsPersistentWithSameIdAs(EntityVersioned <TKey> compareTo)
        {
            if (compareTo == null)
            {
                throw new ArgumentNullException(nameof(compareTo));
            }

            return(!IsTransient && !compareTo.IsTransient && KeyComparer.Equals(Id, compareTo.Id));
        }
        public static System.Type GetTypeUnproxied(EntityVersioned <TKey> obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException(nameof(obj));
            }

            var result = obj.GetType();

            while (IsProxyOrAccessor(result))
            {
                result = result.BaseType;
            }

            return(result);
        }