AutoQuery support for multiple connection strings?

How do I use multiple connection strings (SQL Server) in a ServiceStack application?

I need to perform CRUD actions on two distinct databases (hosted on two different servers) from a single ServiceStack application.

If it is possible, how to I define types for each database?

You’d use dbFactory.RegisterConnection() to register different named db connections to different RDBMS’s. Different ways of changing DB’s are also published on the Multitenancy docs:

https://docs.servicestack.net/multitenancy

Data Models aren’t limited per DB, which ever IDbConnection you use it with, is the one it’s executed against.

Perfect, works like a charm. As always. Thank you.

I went with NamedConnection attribute on the POCO, rather than on each service, to reduce the typing.

1 Like