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:

  • Run AspNet Core app in docker using GMSA
  • Authorization Not working with identityserver4 when using docker
  • Pin ASP.Net 5.0 version to 'beta4' in Dockerfile
  • What is causing these directories to be hidden?
  • Persist ASP.NET Core auth cookies between docker image launches
  • How to locate an core site on subpath
  • 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?

  • How to remove docker support from an ASP.NET Core project?
  • How to persist data in a Docker .NET Core Web app?
  • Deploying docker container to production server from Visual Studio 2017 RTM
  • Docker container with ASP.NET Core libraries
  • How to deploy application to docker container on Linux server?
  • Docker Build and Multi layer dll version
  • 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.