From 443f03688e4661ed23b22b0d564e8b90563ef40f Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> Date: Wed, 11 Oct 2023 10:46:25 +0200 Subject: [PATCH] Fix update to update foreach Group (#14945) --- .../Upgrade/V_14_0_0/AddGuidsToUserGroups.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_0_0/AddGuidsToUserGroups.cs b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_0_0/AddGuidsToUserGroups.cs index c481fc7694c2..32337f8f39f7 100644 --- a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_0_0/AddGuidsToUserGroups.cs +++ b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_0_0/AddGuidsToUserGroups.cs @@ -46,9 +46,13 @@ private void MigrateSqlServer() AddColumnIfNotExists(columns, NewColumnName); // We want specific keys for the default user groups, so we need to fetch the user groups again to set their keys. - IEnumerable updatedUserGroups = Database.Fetch() - .Select(x => x.Key = ResolveAliasToGuid(x.Alias)); - Database.Update(updatedUserGroups); + List? userGroups = Database.Fetch(); + + foreach (UserGroupDto userGroup in userGroups) + { + userGroup.Key = ResolveAliasToGuid(userGroup.Alias); + Database.Update(userGroup); + } scope.Complete(); }