Connecting to MySQL Server on Vagrant Linux VM via SSH with NET 4.8 (C# 7.3)

microwavestine
1 min readJan 5, 2024

[See previous post on how to setup MySQL learning environment.]

I searched for ways to SSH into MySQL with NET 4.8, but all the code samples on Stack Overflow were too complex, or if the examples were easy to follow through, it was targeted for C# 8.

I liked the concise example… only if I could rewrite it in C#7.3 since NET 4.8 default language version is highly recommended to not alter… hmm

Fortunately we live in the age of ChatGPT. With a little help from ChatGPT (it wasn’t 100%, but it helped), and minor tweaks to type casts ChatGPT didn’t recognize, I rewrote the code from C# 8 to 7.3.

NuGet Packages used: Renci.SshNet, Mysql.Data, and DotNetEnv for local secrets management.

The result code can be viewed here.

Here is the full transcript with ChatGPT: https://chat.openai.com/share/b904a1c2-7231-4660-bcbc-e48015ce9150

--

--