Connecting to MySql on Docker
I have an ASP.NET 5 Web API application which I have deployed on docker. It connects to a MySql instance, also on docker. I am using Entity Framework 6 to connect to the MySql database. I have not referenced Entity Framework directly, but am using the MySql.Data.Entity package which internally uses Entity Framework 6.
When I invoke the API, I get this error:
Unable to determine the provider name for provider factory of type ‘MySql.Data.MySqlClient.MySqlClientFactory’
Outside docker, i.e., on my windows machine, in Visual Studio 2015, I point my web API to the MySql instance on docker, and I can connect just fine. Inside docker, I get the error mentioned above.
What could be wrong?
2 Solutions collect form web for “Connecting to MySql on Docker”
The provider name is not being passed. Prior to ASP.NET 5 the
provider value could be set alongside
connectionString in in the web.config. This is no longer the case, as the connection string is just a string value in a json file with no extra properties.
You need to set it programatically. Here’s an example, notably this part;
SetProviderServices("MySql.Data.MySqlClient", new MySqlProviderServices());
I’m not an expert on ASP.NET, but doesn’t your question translate to:
If I run ASP.NET on Windows everything works fine, if I run it on
Linux I get an exception.
I don’t think this is a Docker issue and would rather investigate about issues / driver needs the Entity Framework has on Mono.