I developed a C#/WPF application utilizing Entity Framework 6 to connect to a local MySQL database. The application works perfectly when running on the local computer. However, when I install the application on other systems and run it, it crashes the moment it needs to access the database.
Catching the exception and making a message pop-up, I get the message "Value cannot be null. Parameter name : source." From this post, Value cannot be null. Parameter name: source, I presume that it is because my connection string is wrong or I am not doing something correctly to allow remote database access.
This is my connection string in App.config:
connectionString="metadata=res://*/Database.csdl|res://*/Database.ssdl|res://*/Database.msl;provider=MySql.Data.MySqlClient;provider connection string="server=(ipAddress);user id=root;password=password;persistsecurityinfo=True;database=practice""
The ip address I am using is the real ip address of the local system obtained from cmd => ipconfig => IPv4.
After a lot of googling and searching through stack overflow, I have not yet found a solution to this. I do not want a local instance of the database on the other computers, they should all remotely connect to the database hosted on the local computer. I do not think there should be any issue connecting because all the systems are on the same network and I can ping the computer with the local database from the other computers.
I have tried giving remote access to the other computers in MySQL using the following statements:
CREATE USER '%'@'(IPADDRESS)' IDENTIFIED BY '';
GRANT ALL PRIVILEGES ON *.* TO '%'@'(IPADDRESS)' WITH GRANT OPTION;
Also tried following Asaf's solution in this post (WPF application doesn't work in other computers). However, neither worked for me.
If anyone can explain how to publish a C#/WPF application with access to MySQL database, that would be great.
EDIT: After editing the code more to see the exception, I am getting the error "The underlying provider failed on Open." Looking into that now.
EDIT: SOLVED! Thank you to obl. Needed to enable remote connection as 'root' (How to allow remote connection to mysql), flush privileges, and restart MySQL Server. Afterwards, the application worked.
Thanks to Obl, I solved the problem by enabling remote connection as 'root' (How to allow remote connection to mysql). Afterwards, just had to flush privileges and restart MySQL server.