public async Task<EntityList> InstallSchemaAsync(IApiContext apiContext, EntityList entityList, EntityScope scope, 
            IndexedProperty idProperty,List<IndexedProperty> indexedProperties)
        {

            if (indexedProperties != null && indexedProperties.Count > 4) throw new Exception("Only 4 indexed properties are supported");
            if (string.IsNullOrEmpty(entityList.Name)) throw new Exception("Entity name is missing");

            entityList.TenantId = apiContext.TenantId;
            entityList.ContextLevel = scope.ToString();

            if (indexedProperties != null) { 
                entityList.IndexA = indexedProperties.Count >= 1 ? indexedProperties[0] : null;
                entityList.IndexB = indexedProperties.Count >= 2 ? indexedProperties[1] : null;
                entityList.IndexC = indexedProperties.Count >= 3 ? indexedProperties[2] : null;
                entityList.IndexD = indexedProperties.Count >= 4 ? indexedProperties[3] : null;
            }
            
            if (idProperty == null) entityList.UseSystemAssignedId = true;
            else entityList.IdProperty = idProperty;

            if (string.IsNullOrEmpty(entityList.NameSpace)) 
                entityList.NameSpace = _appSetting.Namespace;

            var entityListResource = new EntityListResource(apiContext);
            var listFQN = GetListFQN(entityList.Name, entityList.NameSpace);
            var existing = await GetEntityListAsync(apiContext, entityList.Name);

            try
            {
                existing = existing != null
                    ? await entityListResource.UpdateEntityListAsync(entityList, listFQN)
                    : await entityListResource.CreateEntityListAsync(entityList);
            }
            catch (AggregateException ae)
            {
                if (ae.InnerException.GetType() == typeof(ApiException)) throw;
                var aex = (ApiException)ae.InnerException;
                _logger.Error(aex.Message, aex);
                throw aex;
            }

            return entityList;
        }
        private void InstallSchema()
        {
            var contactEntityList = new EntityList
            {
                IsSandboxDataCloningSupported = false,
                IsShopperSpecific = false,
                IsVisibleInStorefront = true,
                Name = listName
            };

            var indexProperties = new List<IndexedProperty>()
            {
                _entitySchemaHandler.GetIndexedProperty("firstName", EntityDataType.String),
                _entitySchemaHandler.GetIndexedProperty("lastName", EntityDataType.String)
            };
            var idProperty = _entitySchemaHandler.GetIndexedProperty("id", EntityDataType.Integer);

            _entitySchemaHandler.InstallSchemaAsync(new ApiContext(TenantId), contactEntityList, EntityScope.Tenant,idProperty, indexProperties).Wait();
        }
 public async Task<EntityList> InstallSchemaAsync(IApiContext apiContext, EntityList entityList, EntityScope scope,
     List<IndexedProperty> indexedProperties)
 {
     return await InstallSchemaAsync(apiContext, entityList, scope, null, indexedProperties);
 }