Read and Write Multitenancy

What is the best practice approach to apply a read/write pattern to database access?

I am looking for the following properties:

  1. Ability to ALWAYS Write to Database on Connection A, Sometimes Read from Database on Instance B
  2. Reads will be determined on a DTO Basis whether to read from A or B.
  3. Want to leave the option in play to establish caches at some point
  4. Needs to be enforced server side, not during client connection.

I’m currently working through the multitenancy documentation:

http://docs.servicestack.net/multitenancy

Just wondering if there are any further recommendations based on these requirements.

I guess best approach may be to use NamedConnections ?

Yeah sounds like you want to register different named connections, either with a [ConnectionInfo] attribute on your Services:

[ConnectionInfo(NamedConnection = "ConnectionA")]
public class ConnectionAServices : Service
{
}

Or if you need the flexibility, you can open your named connection inside your Service.

1 Like