Documentation Home
Connectors and APIs Manual
Download this Manual
PDF (US Ltr) - 4.1Mb
PDF (A4) - 4.1Mb


Connectors and APIs Manual  /  ...  /  Installing Connector/NET from Source

4.3.3 Installing Connector/NET from Source

Building MySQL Connector/NET from the source code enables you to customize build parameters and target platforms such as Linux and macOS. The procedures in this section describe how to build source with Microsoft Visual Studio (Windows or macOS) and .NET Core CLI (Windows, macOS, or Linux).

MySQL Connector/NET source code is available for download from https://dev.mysql.com/downloads/connector/net/. Select Source Code from the Select Operating System list. Use the Archive tab to download a previous version of Connector/NET source code.

Source code is packaged as a ZIP archive file with a name similar to mysql-connector-net-8.0.19-src.zip. Unzip the file to local directory.

The file includes the following directories with source files:

  • EFCore: Source and test files for Entity Framework Core features.

  • EntityFramework: Source and test files for Entity Framework 6 features.

  • MySQL.Data: Source and test files for features using the MySQL library.

  • MySQL.Web: Source and test files for the web providers, including the membership, role, profile providers that are used in ASP.NET or ASP.NET Core websites.

Building Source Code with Visual Studio

The following procedure can be used to build the connector on Microsoft Windows or macOS. Connector/NET supports various versions of Microsoft Visual Studio and .NET libraries. For guidance about the Connector/NET version you intend to build, see Section 4.2, “Connector/NET Versions” before you begin.

  1. Navigate to the root of the source code directory and then to the directory with the source files to build, such as MySql.Data. Each source directory contains a Microsoft Visual Studio solution file with the .sln (for example, MySqlData.sln).

  2. Double-click the solutions file to start Visual Studio and open the solution.

    Visual Studio opens the solution files in the Solution Explorer. All of the projects related to the solution also appear in the navigation tree. These related projects can include test files and the projects that your solutions requires.

  3. Locate the project with the same name as the solution (MySql.Data in this example). Right-click the node and select Build from the context menu to build the solution.

Building Source Code with .NET Core CLI

The following procedure can be used to build the connector on Microsoft Windows, Linux, or macOS. A current version of the .NET Core SDK must be installed locally to execute dotnet commands. For additional usage information, visit https://docs.microsoft.com/en-us/dotnet/core/tools/.

  1. Open a terminal such as PowerShell, Command Prompt, or bash.

    Navigate to the root of the source code directory and then to the directory with the source files to build, such as MySQL.Data.

  2. Clean the output of the previous build.

    dotnet clean
  3. Type the following command to build the solution file (MySql.Data.sln in this example) using the default command arguments:

    dotnet build

    Solution and project default.  When no directory and file name is provided on the command line, the default value depends on the current directory. If the command is executed from the top directory, such as MySQL.Data, the solution file is selected (new with the .NET Core 3.0 SDK). Otherwise, if executed from the src subdirectory, the project file is used.

    Configuration default, -c | --configuration Defaults to the Debug build configuration. Alternatively, -c Release is the other supported build configuration argument value.

    Framework default, -f | --framework When no framework is specified on the command line, the solution or project is built for all possible frameworks that apply. To determine which frameworks are supported, use a text editor to open the related project file (for example, MySql.Data.csproj in the src subdirectory) and search for the <TargetFrameworks> element.

    To build source code on Linux and macOS, you must target .NET Standard (-f netstandard2.0 or -f netstandard2.1). To build source code on Microsoft Windows, you can target .NET Standard and .NET Framework (-f net452 or -f net48).