Keith
December 3, 2021, 5:48pm
1
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?
mythz
December 3, 2021, 6:19pm
2
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.
Keith
December 4, 2021, 11:23am
3
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