My IT guy just updated our MySQL database to a new cluster, and now I am getting transient errors like these:
An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure()' to the 'UseMySql' call.
So, after research, I added this code:
options.UseMySQL(Configuration.GetConnectionString(connectionString),
options => options.EnableRetryOnFailure
(
maxRetryCount: 10,
maxRetryDelay: TimeSpan.FromSeconds(30),
errorNumbersToAdd: null
)
);
});
Which then, unfortunately resulted in a new error:
Error CS1061 'MySQLDbContextOptionsBuilder' does not contain a definition for 'EnableRetryOnFailure' and no accessible extension method 'EnableRetryOnFailure'
I have NO idea if I am missing a reference or not, but intellisense doesn't help
So, I do more research and find information here https://dev.mysql.com/doc/connector-net/en/connector-net-entityframework60.html and here https://entityframeworkcore.com/knowledge-base/57595183/using-entity-framework-with-multiple-databases-and-providers-in-the-same-project--sql-server-and-mysql- about using this line from MySQL:
SetExecutionStrategy("MySql.Data.MySqlClient", () => new MySqlExecutionStrategy());
Which also throws errors.
Does anyone know how I can implement Connection Resiliency/Retry Logic using MySQL?
.Net 5, MySQL 5.7, MySqlConnector 8.0.20