abp
abp copied to clipboard
Data is not stored to respective tenant database
ABP Framework version 5.0
User Interface:MVC
database provider: EF Core
Steps needed to reproduce: I have followed the step-by-step process of: https://docs.abp.io/en/abp/latest/Multi-Tenancy and I have added the connection string details of each tenant in "AbpTenantConnectionStrings" and created databases of each tenant( Tenant1 & Tenant2 ) as TODOAPP1 & TODOAPP2 but when I save the data to database the data is stored in the default database (TODOAPP) but not in the tenant-specific database. am I missing anything here? How to configure Per tenant one database?


Name is the name of the connectionstring. You can set Default for it.
yes it is set to default only but the data is getting stored in the default connection/Database, not in the newly created databases (TODOAPP1 & TODOAPP2)


Nope, I have changed it accordingly. it didn't work, data is not stored with the tenant-specific database.

I can not reproduce. Can you provide a simple project to reproduce it?
sample code: https://github.com/saitejkuralla/TodoApp_Multitenancy
Below is the recent change in my code

sample code: https://github.com/saitejkuralla/TodoApp_Multitenancy
404

Below is the recent change in my code
You don't need to modify AbpDbContext. Multi-Tenancy connectionstring switching in abp is out-of-the-box.
updated the repo to "public" but without switching that I am unable to do that, could you help me out with that. the final requirement is to save the data in tenant specific database. By doing the above change the login credentials are part of the default database and I was unable to login now. Note : if there is any sample code for per tenant database that would be great
-
Remove the changes you have made to AbpDbContext.
-
Please submit todo content after select a tenant.It is best to be able to login to the tenant user. Or use other ways of switching tenants (querystring, cookies, header, ...). https://docs.abp.io/en/abp/latest/Multi-Tenancy#tenant-resolvers

Host

Tenant1

querystring switch tenant


sorry for this again the data is saved only in Default Database (TODOAPP) as tenant-specific.
Yes using query string and switching the tenant I have submitted the data
Am I missing anything here

I only removed your changes to AbpDbContext.

select AbpTenants.Id, AbpTenants.Name, AbpTenantConnectionStrings.Name, AbpTenantConnectionStrings.Value
from AbpTenants
left join AbpTenantConnectionStrings on AbpTenants.Id = AbpTenantConnectionStrings.TenantId

If the same code is not working for me hope it should be a bug .is that an environment issue?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.