Replication throw an error after failover mirror partner is down in SQL Server Received an error mentioned below after failover when mirror partner is down.

Error : 


  to fail over to a database which is not configured for database
  mirroring. code: 22037, text: 'Invalid connection string
  attributeCannot open database "DBName" requested by the login. The login
  failed.Login failed for user 'domain\user'.The connection attempted to
  fail over to a database which is not configured for database
  mirroring.'.


Scenario :


X is a Principal server and Y is a mirror partner of X
X is a publisher too, Z is a distributor server
Z is added as distributor in X and Y Server. X and Y added as publisher in Z server too
Configured Y as a "PublisherFailoverPartner" in replication log reader agent profile setting
Did failover of X
Thereafter Y became a principal and X became  mirror partner
Break mirror from Y to X or X server is down and unavailable


After above steps performed, replication is started to throw an error. When mirror is ON the replication is working, otherwise it raising an error mentioned.

Can you please suggest me steps to resolve it?
This should work as it did for me:

Set the -failoverpartner using the mirror name in the sql agents for replication.
Fail mirror over to secondary

Make sure replication continues to send commands to subscriber.

Remove mirroring so primary is no longer connected.

Go to distributor, add an alias (sql server alias)
The alias should be the old principal name pointing to the secondary server.

Replication will continue without errors, however jobs (and replication monitor) will show everything under the primary mirror server.