From 623ec49ed73a360e84a8bac79bb2d34858771258 Mon Sep 17 00:00:00 2001 From: yigith Date: Mon, 15 Jun 2020 20:07:15 +0300 Subject: [PATCH] Making "any" async (#397) * Making "any" async * Removed unused using Co-authored-by: Eric Fleming --- src/Infrastructure/Data/CatalogContextSeed.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Infrastructure/Data/CatalogContextSeed.cs b/src/Infrastructure/Data/CatalogContextSeed.cs index 9ea74b2..97e2251 100644 --- a/src/Infrastructure/Data/CatalogContextSeed.cs +++ b/src/Infrastructure/Data/CatalogContextSeed.cs @@ -1,8 +1,8 @@ -using Microsoft.eShopWeb.ApplicationCore.Entities; +using Microsoft.EntityFrameworkCore; +using Microsoft.eShopWeb.ApplicationCore.Entities; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; namespace Microsoft.eShopWeb.Infrastructure.Data @@ -17,8 +17,7 @@ namespace Microsoft.eShopWeb.Infrastructure.Data { // TODO: Only run this if using a real database // context.Database.Migrate(); - - if (!catalogContext.CatalogBrands.Any()) + if (!await catalogContext.CatalogBrands.AnyAsync()) { catalogContext.CatalogBrands.AddRange( GetPreconfiguredCatalogBrands()); @@ -26,7 +25,7 @@ namespace Microsoft.eShopWeb.Infrastructure.Data await catalogContext.SaveChangesAsync(); } - if (!catalogContext.CatalogTypes.Any()) + if (!await catalogContext.CatalogTypes.AnyAsync()) { catalogContext.CatalogTypes.AddRange( GetPreconfiguredCatalogTypes()); @@ -34,7 +33,7 @@ namespace Microsoft.eShopWeb.Infrastructure.Data await catalogContext.SaveChangesAsync(); } - if (!catalogContext.CatalogItems.Any()) + if (!await catalogContext.CatalogItems.AnyAsync()) { catalogContext.CatalogItems.AddRange( GetPreconfiguredItems());