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:

  • Manually running container exists with code 145
  • Best practice for running a non trusted .net core application inside a docker container
  • Deploying docker container to production server from Visual Studio 2017 RTM
  • Connectionstring from docker container to SQL Server dblocal in host
  • How to attach visual studio 2015 debugger to previously deployed core docker container
  • ASP.NET Core Docker port forwarding on Ubuntu 16.10
  • 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?

  • MySQL -> .NET Core Dependency error (MySql.Data)
  • Cannot connect to SQL Server from a Docker container
  • Persist ASP.NET Core auth cookies between docker image launches
  • Docker-compose up creates container but coudn't start it
  • Docker image size and how much space should I expect 'dnu restore' to take up?
  • Docker for Windows does not work with Volumes
  • 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.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.