diff --git a/src/Core/Entities/Collection.cs b/src/Core/Entities/Collection.cs index 33f6935d3e..d156b3d121 100644 --- a/src/Core/Entities/Collection.cs +++ b/src/Core/Entities/Collection.cs @@ -66,7 +66,7 @@ public class Collection : ITableObject /// Only populated for collections of type DefaultUserCollection. /// Set to null when the OrganizationUser entry is deleted. /// - public Guid? DefaultCollectionOwner { get; set; } + public Guid? DefaultCollectionOwnerId { get; set; } public void SetNewId() { diff --git a/src/Infrastructure.Dapper/Repositories/CollectionRepository.cs b/src/Infrastructure.Dapper/Repositories/CollectionRepository.cs index 8e9156656a..bd5248bd58 100644 --- a/src/Infrastructure.Dapper/Repositories/CollectionRepository.cs +++ b/src/Infrastructure.Dapper/Repositories/CollectionRepository.cs @@ -463,7 +463,7 @@ public class CollectionRepository : Repository, ICollectionRep RevisionDate = DateTime.UtcNow, Type = CollectionType.DefaultUserCollection, DefaultUserCollectionEmail = null, - DefaultCollectionOwner = orgUserId + DefaultCollectionOwnerId = orgUserId }); collectionUsers.Add(new CollectionUser diff --git a/src/Infrastructure.EntityFramework/AdminConsole/Configurations/CollectionEntityTypeConfiguration.cs b/src/Infrastructure.EntityFramework/AdminConsole/Configurations/CollectionEntityTypeConfiguration.cs index aaa86b6573..6d20390740 100644 --- a/src/Infrastructure.EntityFramework/AdminConsole/Configurations/CollectionEntityTypeConfiguration.cs +++ b/src/Infrastructure.EntityFramework/AdminConsole/Configurations/CollectionEntityTypeConfiguration.cs @@ -13,17 +13,17 @@ public class CollectionEntityTypeConfiguration : IEntityTypeConfiguration new { c.DefaultCollectionOwner, c.OrganizationId, c.Type }) + .HasIndex(c => new { c.DefaultCollectionOwnerId, c.OrganizationId, c.Type }) .IsUnique() .HasFilter("[Type] = 1") - .HasDatabaseName("IX_Collection_DefaultCollectionOwner_OrganizationId_Type"); + .HasDatabaseName("IX_Collection_DefaultCollectionOwnerId_OrganizationId_Type"); // Configure FK with NO ACTION delete behavior to prevent cascade conflicts // Cleanup is handled explicitly in OrganizationUserRepository.DeleteAsync builder .HasOne() .WithMany() - .HasForeignKey(c => c.DefaultCollectionOwner) + .HasForeignKey(c => c.DefaultCollectionOwnerId) .OnDelete(DeleteBehavior.NoAction); builder.ToTable(nameof(Collection)); diff --git a/src/Infrastructure.EntityFramework/AdminConsole/Repositories/OrganizationUserRepository.cs b/src/Infrastructure.EntityFramework/AdminConsole/Repositories/OrganizationUserRepository.cs index c8c453f224..0edd5e9ccd 100644 --- a/src/Infrastructure.EntityFramework/AdminConsole/Repositories/OrganizationUserRepository.cs +++ b/src/Infrastructure.EntityFramework/AdminConsole/Repositories/OrganizationUserRepository.cs @@ -115,7 +115,7 @@ public class OrganizationUserRepository : Repository c.RevisionDate, utcNow) .SetProperty(c => c.DefaultUserCollectionEmail, c => c.DefaultUserCollectionEmail == null ? email : c.DefaultUserCollectionEmail) - .SetProperty(c => c.DefaultCollectionOwner, (Guid?)null)); + .SetProperty(c => c.DefaultCollectionOwnerId, (Guid?)null)); await dbContext.CollectionUsers .Where(cu => cu.OrganizationUserId == organizationUser.Id) diff --git a/src/Infrastructure.EntityFramework/Repositories/CollectionRepository.cs b/src/Infrastructure.EntityFramework/Repositories/CollectionRepository.cs index bbb0de743b..e00fd8d7af 100644 --- a/src/Infrastructure.EntityFramework/Repositories/CollectionRepository.cs +++ b/src/Infrastructure.EntityFramework/Repositories/CollectionRepository.cs @@ -842,7 +842,7 @@ public class CollectionRepository : Repository