'How do i add a User to a Database that is in an always on Availability group?

i have a an always on availability group with one database called Mydb, 1 Primary Replica - MyReplica1 and 1 secondary - MyReplica2 in Async Commit. It is also a readable secondary.

I want to add a new login and map it as DBO in the database Mydb.

Creating the login and mapping in MyReplica1 is fine with no issues. Creating Login on MyReplica2 is fine but i cannot map it or create the user as i get the error below

Failed to update database "Mydb" because the database is read only. (Microsoft SQL Server, Error: 3906)

Any thoughts on how i can go about this without having to failover to the Secondary just to create the Login.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source