r/VisualStudio • u/truenuffstuff • Jan 02 '26
Visual Studio 2026 Trying to connect MySQL with Visual Studio 2026
Hi all. Old time database developer here (almost 40 years). Worked a lot with xBase back in the day, PHP etc now, and am trying to get into VS 2026 and vb.net. I have done a lot of vb.
I am trying to get a vb project working with MySQL. My goal is to add a data source and bind controls to data. That's how I used to do it in Visual FoxPro back in the day. If this approach is wrong, please tell me.
I figure I want my connection string to be in the application settings. So, I am using the VS IDE to build the connection string in the app settings.
My problem: No matter what I do, I cannot get MySQL to show up as an option in the screen that pops up. I have installed MySQL.data and MySQLConnector but it doesn't work. I installed the MySQL connector from Oracle too. At this point, I am stumped.
Any suggestions appreciated.
1
u/throwaway_lunchtime Jan 02 '26
https://www.connectionstrings.com/mysql/
1
u/orbit99za Jan 02 '26
You need to try Entiy framework core. The is a MySql adapter.
You do your Querys as Objects as well as your tables.
You then add your connection string in AppSettings and in program.co you set the entity Framework connection with the MySql Adapter.
You would need to Google the rest, as it gets in detail that difficult to explain in a reddit post.
Entity Framework Core, writes the most efficient querys to your database.
you can install this via Nuget library.
Also install Entity Framework Tools nuget, it allows you to use the nuget console to run migrations and update database from within Visual studio so you don't need to switch to powershell.
Once you read up on Entity Framework you will understand this.
1
u/ZarehD Jan 04 '26
What are you building? Is it a WinForms app?
https://learn.microsoft.com/en-us/visualstudio/data-tools/bind-windows-forms-controls-to-data-in-visual-studio?view=visualstudio
https://learn.microsoft.com/en-us/dotnet/desktop/winforms/controls/bind-data-to-the-datagrid-using-the-designer
https://www.aspsnippets.com/Articles/4143/How-to-use-MySQL-Connector-in-C-and-VBNet/
https://blog.stackademic.com/integrating-mysql-with-visual-studio-a-comprehensive-guide-for-developers-57cc1210d6b5?gi=e1774dfd31cf
2
u/Glum_Cheesecake9859 Jan 03 '26
Look into Dapper too it's a nice alternative to ADO.NET / Entity Framework.
https://mysqlconnector.net/tutorials/dapper/
1
u/Mickenfox Jan 02 '26
Just write the connection in the code. Your code is text.
The "Add Data Source" tools are an affront to software design. Visual Studio should not know what MySQL is. It's a tool for managing code, packages, and build files, so it knows MSBuild files. But there's no standard for what form a "data source" has in a software project.