public static async Task SeedAsync(RazorCRUDContext context, ILoggerFactory loggerFactory, int?retry = 0)
        {
            int retryForAvailability = retry.Value;

            try
            {
                // TODO: Only run this if using a real database
                //context.Database.Migrate();
                //context.Database.EnsureCreated();
                if (!context.Categories.Any())
                {
                    context.Categories.AddRange(GetPreconfiguredCategories());
                    await context.SaveChangesAsync();
                }
                if (!context.Products.Any())
                {
                    context.Products.AddRange(GetPreconfiguredProducts());
                    await context.SaveChangesAsync();
                }
            }
            catch (Exception exception)
            {
                if (retryForAvailability < 10)
                {
                    retryForAvailability++;
                    var log = loggerFactory.CreateLogger <RazorCRUDSeed>();
                    log.LogError(exception.Message);
                    await SeedAsync(context, loggerFactory, retryForAvailability);
                }
                throw;
            }
        }
 public ProductRepository(RazorCRUDContext context)
 {
     _context = context;
 }