public void AddOrUpdate(TypedEntity entity)
        {
            Transaction.EnsureBegun();

            // First, call Schemas.AddOrUpdate for the schema
            if (Schemas != null && Schemas.CanWrite && entity.EntitySchema != null)
            {
                Schemas.AddOrUpdate(entity.EntitySchema);
            }

            entity.Id = new HiveId((Uri)null, entity.Id.ProviderId, entity.Id.Value);

            if (Revisions.CanWrite)
            {
                var newRevision = new Revision <TypedEntity>(entity);
                Revisions.AddOrUpdate(newRevision);
                OnAddOrUpdateComplete(entity);
                return;
            }
            else
            {
                PerformAddOrUpdate(entity);
                OnAddOrUpdateComplete(entity);
            }

            AddCacheFlushesToTransaction(entity.Id);
        }