Open Closed

Custom ConnectionStringResolver Issue #9350


User avatar
0
Spospisil created

Hi,

I have implemented a custom ConnectionStringResolver class but the ICurrentTenant implementation does not resolve to the current logged in tenant. However I can't even get ABP's solutions to run even if I exclude this resolver class. At this point I have grown very tired of getting any sample projects to work to show support when I generate them using ABP tools, so I'll just give you the generated solution and you can figure out how to get it to run first and then we can have a discussion about the CurrentTenant issue I am having.

Can't waste yet another day trying to get a stock generated ABP solution to run

Steps to Reproduce:

  1. Get stock ABP generated solution to compile/run (Good luck as I've spend 2 days attempting to get it generated and to even work)
  2. Login in as host admin and create a Tenant of 'KENCO' with a non-shared DB (tenant has their own db)
  3. Login in as the KENCO tenant admin
  4. Monitor the debug messages I've added to the CFDMultiTenantConnectionStringResolver.cs class
  5. Observe the CurrentTenant variable still being set to null
  6. I've not been able to verify this test project will reproduce the issue I am experiencing as I've stated above I can't even get the ABP tool generated solution to compile/run

https://github.com/spospisil/ABPSampleTenant.git


57 Answer(s)
  • User Avatar
    0
    Spospisil created

    Hi,

    Just get the code up and running and then create the initial db. Log in as admin (host user) create a tenant (which will create new db) and then log in as that tenant user. Go to the 'companies' link in the left nav bar and you'll see that the current tenant is not set correctly otherwise 2 companies would be showing there.

    I've also put the Current Tenant Name and ID on the default page when you log in as a tenant and you'll see they don't contain the specific tenant information.

    I suspect that you will not be able to get the code up and running as our solution is complicated, so I think you're best bet is to just look at the code in question (probably the login in logic) and tell me what might be wrong that is causing the CurrentTenant not to be set properly.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    So I need to change the connection string and run DbMigrator to initialize the database

    Then run CFData.Structure.AuthServer, CFData.Structure.HttpApi.Host and CFData.Structure.Blazor

    Log in to Blazor -> AuthServer to reproduce the problem?

    Are those steps correct?

    Thanks.

  • User Avatar
    0
    Spospisil created

    Hi,

    Yes that is correct.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Can you share the DevExpress nuget source?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    If you think your problem is in Login.cs, I think you can reproduce the problem in a new template project and share it with us.

  • User Avatar
    0
    Spospisil created

    As I have already told you I have not been able to reproduce the issue with a new template.....hence why I'm sharing our source code with you so you can take a look at it.

  • User Avatar
    0
    Spospisil created

    you can look at the NuGet.Config.Online file to get the devexpress nuget source

  • User Avatar
    0
    Spospisil created

    I'm not convinced the login page is the issue as even if I use ABP's version of the login page (with the tenant switcher) the CurrentTenant object still is not populated properly.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    ok I will check the code and try to find the reason.

    Do you have a online website to reproduce?

  • User Avatar
    0
    Spospisil created

    Hi,

    Thank you for looking into this. No, we don't currently have a site deployed where this issue exists. We are in the process of migrating our code from abp7 to abp9 and now are experiencing this issue.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    I have successfully run your project and will check it as soon as possible.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    ******* Current Tenant IS NOT resolved *******

    If your entity(eg, UserPermissionView) is not implemented with the IMultiTenant interface, the currentTenant will be null even if there is a tenant claim.


  • User Avatar
    0
    Spospisil created

    Hi,

    Can you commit your changes to github for me please so I can take a look?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    https://github.com/spospisil/ABP9Integration/commit/9e61bf3a5c2d9444d2c8a37b5250d998d7b3371e

  • User Avatar
    0
    Spospisil created

    Hi,

    I'm a little confused. Your commit was only 1 file and had nothing to do with the entity you spoke about. Did you try going to the 'companies' nav item? Do 2 companies show on the Company Management page if you do?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you use my code to check Company Management page?

    I got an error when visit this pageERR] 42P01: relation "vw_securityuserpermissions" does not exist

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    New error:

    42P01: relation "Companies" does not exist
    
    POSITION: 358
    Npgsql.PostgresException (0x80004005): 42P01: relation "Companies" does not exist
    
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Can you test it on your side?

  • User Avatar
    0
    Spospisil created

    Companies should have gotten created when you created the new tenant. I'm in the process of building on my side so I can see.....it takes a while though.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    I can see the tenant exists in this request.

  • User Avatar
    0
    Spospisil created

    Ok, what you are showing me looks correct....however what I'm not understanding is the UserPermissionView entity that you mentioned isn't even used on the Company Management screen so why would that affect the current tenant not being accessible? My initial problem started when I couldn't see the companies because the current tenant was not set and the datafilter thus didn't get applied for the query behind this page.

    Why would an entity not implanting the IMultiTenant interface even be relevant on a page that doesn't use it?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I think you can test it with your DB, the page will work.

  • User Avatar
    0
    Spospisil created

    Hi,

    But you didn't answer my question

    "Ok, what you are showing me looks correct....however what I'm not understanding is the UserPermissionView entity that you mentioned isn't even used on the Company Management screen so why would that affect the current tenant not being accessible? My initial problem started when I couldn't see the companies because the current tenant was not set and the datafilter thus didn't get applied for the query behind this page.

    Why would an entity not implanting the IMultiTenant interface even be relevant on a page that doesn't use it?"

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Your Blazor will send some api requests to the backend. And an error happened.

  • User Avatar
    0
    Spospisil created

    Hi,

    Can you please give me the details of this? I spend 3 weeks trying to resolve this issue where as when my code was based on ABP7 it all worked. Now with ABP9 I encountered this issue. You explained the cause of the issue was an entity (not implementing the IMultiTenant interface) that isn't even used on the Company Management screen. So for a 3rd time I am asking you to please provide me with more detail in why this was occurring

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.0.0-preview. Updated on September 01, 2025, 08:37