public static async Task AddRandomCategoriesAsync(this ITypeContext typeContext, Authentication authentication, DataBaseSettings settings) { var minCount = settings.TypeContext.MinTypeCategoryCount; var maxCount = settings.TypeContext.MaxTypeCategoryCount; var count = RandomUtility.Next(minCount, maxCount); var typeCategoryCollection = typeContext.GetService(typeof(ITypeCategoryCollection)) as ITypeCategoryCollection; while (await typeCategoryCollection.GetCountAsync() < count) { await typeContext.AddRandomCategoryAsync(authentication); } }