Closed 274188A closed 1 year ago
Debugging this a bit more - so after switching to the XYZ
tenant and trying to add the Role to the user I see this:
So this pic show the tenant being in context is wrong - it should be XYZ
(not ABC
).
So I see the GetTenant() function uses the Host address to identify a single unique host.
I changed the XYZ Tenants run on 5002 - but we still have the problem because this data is not used anywhere when running the app (ie all tenants run on 5001 in my case).
Closing this to ask a related question - the point is the developer must ensure the Tenant Host is a URL and that it's unique to the tenant
Let's keep the discussion in the forum thread which you have opened.
Exception thrown : System.InvalidOperationException: Role XYZ_ADMIN does not exist.
Environment Blazor Studio (1.9.0) Visual Studio 2022 (Latest Stable) SQL Server 2019 Blazor Server with 'CRUD' template ASP.NET CORE Identity Window 10 latest
Tenants-Roles-Users Tenants
Roles
Users
UserRoles (only user in ABC tenant successfully add to Role)
GIF
To see source code to reproduce go to this repo: https://github.com/274188A/radzen-issue To set up the same db use the file here.
Select Tenant 'XYZ'
Click User and edit Save with Role
Stack Trace
This exception was originally thrown at this call stack: [External Code] System.InvalidOperationException HResult=0x80131509 Message=Role XYZ_ADMIN does not exist. Source=Microsoft.AspNetCore.Identity.EntityFrameworkCore StackTrace: at Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStored106.MoveNext()
at BugTest.Controllers.ApplicationUsersController.d 10.MoveNext() in C:\Users\274188A\source\repos\JUNK\issue\Controllers\ApplicationUsersController.cs:line 117
9.<AddToRoleAsync>d__34.MoveNext() at Microsoft.AspNetCore.Identity.UserManager
1.This exception was originally thrown at this call stack: [External Code] BugTest.Controllers.ApplicationUsersController.Patch(string, BugTest.Models.ApplicationUser) in ApplicationUsersController.cs
dotnet --info .NET SDK: Version: 7.0.203 Commit: 5b005c19f5
Runtime Environment: OS Name: Windows OS Version: 10.0.19044 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\7.0.203\
Host: Version: 7.0.5 Architecture: x64 Commit: 8042d61b17
.NET SDKs installed: 6.0.311 [C:\Program Files\dotnet\sdk] 7.0.203 [C:\Program Files\dotnet\sdk]
.NET runtimes installed: