db-per-tenant | tenant CUBA application with separate databases | Database library
kandi X-RAY | db-per-tenant Summary
kandi X-RAY | db-per-tenant Summary
This application demonstrates an approach to implement a multi-tenant application with separate databases containing domain data for each tenant. Information about users and security settings are stored in a shared database. After a user logs in, the application determines a tenant database for the user and all subsequent requests for domain entities go to this database.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Gets a database connection
- Determine the lookup key to use for the current user session
- Determine the target data source
- Binds the properties
- Creates a datasource for the given address
db-per-tenant Key Features
db-per-tenant Examples and Code Snippets
Community Discussions
Trending Discussions on db-per-tenant
QUESTION
I found many similar questions and posts how to do it, but I'm not sure which approach is better. I think that I need some DbContextFactory class which will return me context depending on the TenantId, but I don't know how to achieve this with OnModelCreating. I mostly saw posts about db-per-tenant architecture, and I'm not sure that I know how to bound schema to context(via user?). I tried to follow this https://romiller.com/2011/05/23/ef-4-1-multi-tenant-with-code-first/ but looks like this is not suitable for latest EF version. I also checked this Multi-Tenant With Code First EF6 but IDbModelCacheKeyProvider changed and now requires DbContext in Create, opposite to what I want to do. Can you please give me example of how this is done?
...ANSWER
Answered 2019-Jan-14 at 08:38Use this code to set a default schema in your context:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install db-per-tenant
You can use db-per-tenant like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the db-per-tenant component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page