I have AlwaysOn setup among two nodes running 2016 enterprise edition. The option Readable Secondary
is set to Read-intent only
.
On using the parameter ApplicationIntent=ReadOnly
it is always redirected to secondary for read operations. But our application also performs writes on database, which cannot happen at secondary due to the above parameter.
Is there any other parameter or setting which redirects reads to secondary and writes to primary? Else, do we need to maintain two connection strings in application, one for writes and other for reads?
You do need two types connection strings in your application. One is for readonly. One is for write and read.
For readonly connection, the connection string needs to have "ApplicationIntent=Readonly".
For write and read connection, the connection string do not include "ApplicationIntent"