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
This commit is contained in:
parent
68d0783070
commit
954d8718a8
@ -33,7 +33,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data
|
|||||||
|
|
||||||
if (!context.Users.Any())
|
if (!context.Users.Any())
|
||||||
{
|
{
|
||||||
await context.Users.AddRangeAsync(useCustomizationData
|
context.Users.AddRange(useCustomizationData
|
||||||
? GetUsersFromFile(contentRootPath, logger)
|
? GetUsersFromFile(contentRootPath, logger)
|
||||||
: GetDefaultUser());
|
: GetDefaultUser());
|
||||||
|
|
||||||
|
@ -27,17 +27,17 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data
|
|||||||
|
|
||||||
if (!await context.Clients.AnyAsync())
|
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())
|
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())
|
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();
|
await context.SaveChangesAsync();
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
if (!context.CardTypes.Any())
|
if (!context.CardTypes.Any())
|
||||||
{
|
{
|
||||||
await context.CardTypes.AddRangeAsync(useCustomizationData
|
context.CardTypes.AddRange(useCustomizationData
|
||||||
? GetCardTypesFromFile(contentRootPath, logger)
|
? GetCardTypesFromFile(contentRootPath, logger)
|
||||||
: GetPredefinedCardTypes());
|
: GetPredefinedCardTypes());
|
||||||
|
|
||||||
@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
if (!context.OrderStatus.Any())
|
if (!context.OrderStatus.Any())
|
||||||
{
|
{
|
||||||
await context.OrderStatus.AddRangeAsync(useCustomizationData
|
context.OrderStatus.AddRange(useCustomizationData
|
||||||
? GetOrderStatusFromFile(contentRootPath, logger)
|
? GetOrderStatusFromFile(contentRootPath, logger)
|
||||||
: GetPredefinedOrderStatus());
|
: GetPredefinedOrderStatus());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user