Exception has occurred: CLR/System.ArgumentNullException
Exception thrown: 'System.ArgumentNullException' in System.Linq.dll: 'Value cannot be null.'
at System.Linq.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
at Volo.Abp.Identity.IdentityUser.IsInOrganizationUnit(Guid organizationUnitId)
at Volo.Abp.Identity.IdentityUser.AddOrganizationUnit(Guid organizationUnitId)
at Iwell.Cloud.Portal.IdentityServer.UserDataSeedContributor.<SeedAsync>d__8.MoveNext() in /app/aspnet-core/src/Iwell.Cloud.Portal.Domain/IdentityServer/UserDataSeedContributor.cs:line 67
When we seed a fresh (development) database we do a few things in a specific order (order managed by a single DataSeedContributor):
Customers
|
-- Customer A
The problem occures in the userseeder when trying to add a user to an existing OU: (all checks and other code left out for readability)
var customerAOU = await _organizationUnitRepository.FirstOrDefaultAsync(ou => ou.DisplayName == IdentityServerConsts.GetCustomerAOUDisplayName());
var customer = await _identityUserManager.FindByNameAsync(IdentityServerConsts.GetCustomerUserName());
customer.AddOrganizationUnit(customerAOU.Id);
The ArgumentNullException happens on the customer.AddOrganizationUnit(..) call.
As you can see in the attached picture the 'customerAOU' is an existing OrganizationUnit object and the 'customer' is an existing IdentityUser object.
The exact same thing happens when trying to add a role to a user using this code:
var adminRole = await _identityRoleManager.FindByNameAsync("admin");
customer.AddRole(adminRole.Id);
I wonder if this is the way to add users to OU's (+ roles to users) or am I missing something here? Is there by any chance some more (technical or reference) documentation available on this topic?
If you need more information, or pieces of code, just let me know.
Any help would be appreciated!
Best regards,