From 954d8718a8903e446f09ad0b9534b4d30ea95476 Mon Sep 17 00:00:00 2001 From: Miguel Veloso Date: Tue, 20 Feb 2018 23:35:41 +0000 Subject: [PATCH] Fix improper use of AddRangeAsync for seeding entities that don't use the SequenceHiLo key generation strategy, as per https://docs.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.dbset-1.addrangeasync?view=efcore-2.0 --- .../Identity/Identity.API/Data/ApplicationDbContextSeed.cs | 2 +- .../Identity.API/Data/ConfigurationDbContextSeed.cs | 6 +++--- .../Ordering.API/Infrastructure/OrderingContextSeed.cs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Services/Identity/Identity.API/Data/ApplicationDbContextSeed.cs b/src/Services/Identity/Identity.API/Data/ApplicationDbContextSeed.cs index 058c58dbc..3dbf28171 100644 --- a/src/Services/Identity/Identity.API/Data/ApplicationDbContextSeed.cs +++ b/src/Services/Identity/Identity.API/Data/ApplicationDbContextSeed.cs @@ -33,7 +33,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data if (!context.Users.Any()) { - await context.Users.AddRangeAsync(useCustomizationData + context.Users.AddRange(useCustomizationData ? GetUsersFromFile(contentRootPath, logger) : GetDefaultUser()); diff --git a/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs b/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs index db43c6019..b109bf896 100644 --- a/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs +++ b/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs @@ -27,17 +27,17 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data if (!await context.Clients.AnyAsync()) { - await context.Clients.AddRangeAsync(Config.GetClients(clientUrls).Select(client => client.ToEntity())); + context.Clients.AddRange(Config.GetClients(clientUrls).Select(client => client.ToEntity())); } if (!await context.IdentityResources.AnyAsync()) { - await context.IdentityResources.AddRangeAsync(Config.GetResources().Select(resource => resource.ToEntity())); + context.IdentityResources.AddRange(Config.GetResources().Select(resource => resource.ToEntity())); } if (!await context.ApiResources.AnyAsync()) { - await context.ApiResources.AddRangeAsync(Config.GetApis().Select(api => api.ToEntity())); + context.ApiResources.AddRange(Config.GetApis().Select(api => api.ToEntity())); } await context.SaveChangesAsync(); diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs b/src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs index 4f3f0b0f2..53c53f052 100644 --- a/src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs +++ b/src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs @@ -39,7 +39,7 @@ if (!context.CardTypes.Any()) { - await context.CardTypes.AddRangeAsync(useCustomizationData + context.CardTypes.AddRange(useCustomizationData ? GetCardTypesFromFile(contentRootPath, logger) : GetPredefinedCardTypes()); @@ -48,7 +48,7 @@ if (!context.OrderStatus.Any()) { - await context.OrderStatus.AddRangeAsync(useCustomizationData + context.OrderStatus.AddRange(useCustomizationData ? GetOrderStatusFromFile(contentRootPath, logger) : GetPredefinedOrderStatus()); }