Currently trying to create a connection to a MySql Database. When I added
using MySql.Data;
using MySql.Data.MySqlClient;
to my class I recieved the typical "The type or namespace name ... could not be found". A little searching made me realize I was missing the MySql.Data.dll.
I used Packet Manager console to install MySql.Data:
PM> Install-Package MySql.Data
I verified that it was installed via Tools > NuGet Package Manager > Manage NuGet Packages for Solutions, but I was still getting the build error.
At this point I figured, since the PM downloaded the .dll I'll just manually reference it via References > Add Reference > Browse > Select MySql.Data.dll.
Great!! The red squiggly went away on my using
and intellisense started working for classes inside the MySql.Data namespace:
Fast forward 10 mins, I finish writing my test class and hit Build and error comes back:
So in summary, using PM to install MySql.Data got me no where. Manually adding the reference of MySql.Data.dll got my intellisense to recognize the namespace and classes, but when it comes to building I still get the error.
Pretty stumped. Anyone seen this?
Solved this issue! Turns out the newest MySql.Data.dll is built off of .Net Framework 4.5.2, while my project was using .Net Framework 3.5 Client Profile.
Changing my project's framework to 4.5.2 solved the issue. It's quite strange that VS doesn't give a better error message.
To change your project's framework right click on your project (not the solution), select Properties -> Application -> Target framework. The target framework is a dropdown on that page.
I came to this realization thanks to another stackoverflower question: Namespace not recognized (even though it is there)
In terminal after navigating to your project directory, run the following commands
dotnet add package MySql.Data -v 8.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With