Activities of "MarekH"

Answer

hi

If your tenant has a separate connection string, you should switch the tenant of the current context to switch the DbContext using a different connection string.

https://docs.abp.io/en/abp/latest/Multi-Tenancy#change-the-current-tenant

You should not create DbCotext manually, abp will manage it automatically.

Hello Maliming,

Thanks for giving above answer its helpful to us.

I have check that we are able to switch the tenant by using CurrentTenant.Change() method in HttpApi.Host Layer you can see the below image.It's working

I have tried the same way with micro-service (Create new micro-service) and write similar code which is in above image and call the api. At that time I am not able to call api, it gives a 500 error. I have also added reference of Application layer and added related reference project.

Can we access the Repository of any table in micro-service ? Please provide some step for access the table repository in micro-service

Question
  • ABP Framework version: v4.3.0
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace:
  • Steps to reproduce the issue:

Hello, we are trying to resolve issues related to switching between host and customer DBs.

Our purpose :- Insert,Update and Get data as per the connectionString of tenant from Host layer API as well as from newly created Microservice layer API

I was trying to switch the database using connection string So I added one method ContextFactory in DbContext.cs file(EntityFrameworkCore layer)

Create a sample API in Demo.HttpApi.Host layer and Call the ContextFactory method which returns a given connectionString context object.

Using that object i am able to access all the tables but getting error 'Object reference not set to an instance of an object'

My question is:how can we change the context and get the data from Host layer API as well as Microservice API ?

after

Ok thank you. For the quick response ,

We will work on it.

Hello Maliming

We are waiting for demo ,We are using separate identity server with angular as a front end. Do we have demo for that?

I will create demos that use domain names to resolve tenants. MVC and ANGULAR.

Ok Thank you.

hi @MarekH

I am going to check your application remotely. Please tell me your available time. liming.ma@volosoft.com

Hi @Maliming

We will available after an hour (02:00 PM IST) is this fine for you ?

hi @MarekH

Deos tenant1.mydomain.com and authserver.mydomain.com both use mydomain.com as domain?

Yes both are in same domain

Configure<AbpTenantResolveOptions>(options => { options.AddDomainTenantResolver("{0}.mydomain.com"); });

We have added above method , to switch tenant autometically on the basis of URL change

To clarify:

  1. In tenant1.mydomain.com hit login
  2. Redirected to authserver.mydomain.com (identityserver), enter credentials for admin user and hit login
  3. Successfuly signed in and I am now redirected back to tenant1.mydomain.com.
  4. But logged in user is not tenant admin but the host admin?

But tenant is not getting changed , We are still logged in as admin.

I assume Host admin, not tenant admin.

It might be related with cookies and application cache. Does it the same behaviour when you cleared the cookies and browser cache or in incognito mode?

Yes , It is same behaviour when we clear cookie.

We are getting logged in as HostAdmin instead of tenant Admin

We have used below method to enable tenant switching on the basis of URL:-

Configure<AbpTenantResolveOptions>(options => { options.AddDomainTenantResolver("{0}.mydomain.com"); });

Do we need anything else for switching tenant on the basis of URL?

Actually we are trying to switch tenant on the basis of change in the URL , Instead of switching it from the popup modal which we have in the login. We have tried below things :-

  1. Created Custom tenant Resolver class also added {0}.maindomain.com specified this URL. As we found this solution to switch tenant autometically on the basis of URL.

In current scenario we are getting that URL after login for example if we use

tenant1.mydomain.com then after login we are redirecting to same tenant1.mydomain.com But tenant is not getting changed , We are still logged in as admin.

Can you please help us.

We are facing this issue while we are trying to login using url.

We have tried to login as tenant, login is successfully done however we got an error of Invalid_scope.

This shows login happened for tenant6 admin user. Do you mean this doesn't work anymore either?

We have resolved this error but we are not able to login as tenant using url

Showing 11 to 20 of 26 entries
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11