public static async Task SeedAsync(CloudContext CloudContext, ILoggerFactory loggerFactory, int?retry = 0) { int retryForAvailability = retry.Value; try { // TODO: Only run this if using a real database // context.Database.Migrate(); if (!CloudContext.CatalogBrands.Any()) { CloudContext.CatalogBrands.AddRange( GetPreconfiguredCatalogBrands()); await CloudContext.SaveChangesAsync(); } if (!CloudContext.CatalogTypes.Any()) { CloudContext.CatalogTypes.AddRange( GetPreconfiguredCatalogTypes()); await CloudContext.SaveChangesAsync(); } if (!CloudContext.CatalogItems.Any()) { CloudContext.CatalogItems.AddRange( GetPreconfiguredItems()); await CloudContext.SaveChangesAsync(); } } catch (Exception ex) { if (retryForAvailability < 10) { retryForAvailability++; var log = loggerFactory.CreateLogger <CloudContextSeed>(); log.LogError(ex.Message); await SeedAsync(CloudContext, loggerFactory, retryForAvailability); } } }
public EfRepository(CloudContext dbContext) { _dbContext = dbContext; }
public OrderRepository(CloudContext dbContext) : base(dbContext) { }