Base solution for your next web application
Open Closed

One database for each tenant #165


User avatar
0
agunghehe created

Hi,

I would like to know if there is possibility i could have one database for each tenant by using current code? If not, would you give me some hints in particular area i need to enhance?

Thanks


2 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Abp-zero currently supports one-database multi-tenancy and it may not be very simple to change it since it's an architectural design.

    In a multi-tenant multi-database approach, you probably have a master database which contains a table for tenants and stores database connection for each tenant. When user login, you will get tenant connection, write it to some session and then connect this db on next requests. I suppose, general principle should be similar that. But there are also some maintaince issues for db-per-tenant approach. For example, you should run migrations for each database when schema changes. You should backup databases seperately...

  • User Avatar
    0
    agunghehe created

    Hi Mate, many thanks for the quick response. I am very glad with the answer.

    Following up about this, do you know how to repopulate the DBContext so that the connection comes from the tenant connection string? (I am using ABP, instead of ABPZero for now). This means just after the first DBContext do query to look at the tenant conn string, then i am hoping i can re-populate the DBContext with the tenant conn string. As far as i know the initialization of the DBContext is started at AbpBootstraper.

    Many thanks for your response.

    Regards,

    Agung