Browse Source

Merge pull request #517 from mvelosop/fix-async-context-seed

Fix improper use of AddRangeAsync for seeding entities
pull/493/merge
Miguel Veloso 7 years ago
committed by GitHub
parent
commit
1d1c815463
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions
  1. +1
    -1
      src/Services/Identity/Identity.API/Data/ApplicationDbContextSeed.cs
  2. +3
    -3
      src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs
  3. +2
    -2
      src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs

+ 1
- 1
src/Services/Identity/Identity.API/Data/ApplicationDbContextSeed.cs View File

@ -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());


+ 3
- 3
src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs View File

@ -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();


+ 2
- 2
src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs View File

@ -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());
}


Loading…
Cancel
Save