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:

  • Docker for Windows does not work with Volumes
  • Running .net core docker image, says application started, but on browsing gives “This site can’t be reached” error
  • dotnet aspnetcore docker build fails with a 145 error code
  • Pin ASP.Net 5.0 version to 'beta4' in Dockerfile
  • Deploying ASPNET core app in IIS inside Docker Container
  • Pass optional arguments when running a Docker image
  • 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?

  • Not able to deploy ASP .net vnext application on VM on Azure using Docker
  • Assetss from wwwroot cannot be found on Docker Image
  • What is the correct ENTRYPOINT for Asp.net Core RC2 Dockerfile
  • Build ASP.NET Core 1.1 preview4 project in Docker-image microsoft/aspnetcore-build:1.1.0-msbuild
  • How can I provide application config to my .NET Core Web API services running in docker containers?
  • Connect to SQL Server database from a docker container
  • 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.