Skip to content

Commit 13d7fa6

Browse files
committed
Add migration notes on async.
1 parent c5bdd60 commit 13d7fa6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

docs/content/tutorials/migrating-from-connector-net.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,18 @@ for the client’s private key (in PFX format); `SslCa` (aka `CACertificateFile`
6868
Some connection string options that are supported in Connector/NET are not supported in MySqlConnector. For a full list of options that are
6969
supported in MySqlConnector, see the [Connection Options](connection-options).
7070

71+
### Async
72+
73+
Connector/NET implements the standard ADO.NET async methods, and adds some new ones (e.g., `MySqlConnection.BeginTransactionAsync`,
74+
`MySqlDataAdapter.FillAsync`) that don't exist in ADO.NET. None of these methods have an asynchronous implementation,
75+
but all execute synchronously then return a completed `Task`. This is a [longstanding known bug](https://bugs.mysql.com/bug.php?id=70111)
76+
in Connector/NET.
77+
78+
Because the Connector/NET methods aren't actually asynchronous, porting client code to MySqlConnector (which is asynchronous)
79+
can expose bugs that only occur when an async method completes asynchronously and resumes the `await`-ing code
80+
on a background thread. To avoid deadlocks, make sure to [never block on async code](https://blog.stephencleary.com/2012/07/dont-block-on-async-code.html) (e.g., with `.Result`), use async all the way, use `ConfigureAwait` correctly,
81+
and follow the [best practices in async programming](https://msdn.microsoft.com/en-us/magazine/jj991977.aspx).
82+
7183
### Implicit Conversions
7284

7385
Connector/NET allows `MySqlDataReader.GetString()` to be called on many non-textual columns, and will implicitly

0 commit comments

Comments
 (0)