.NET Core on Connector/NET updates.

Hello MySQL Connector/NET community,

Consistent with our ongoing effort to power MySQL products with the top technologies, we are pleased to announce the latest updates regarding MySQL Connector/NET and .NET Core.

And while we move forward, we also want to shape the product to maximize supportability. To achieve these two goals, we will deprecate the support for .NET Core 1.X to align with Microsoft’s end-of-life schedule (EOL May 14, 2019). But it’s not all about bad news, we also want to talk to you about the inclusion of .NET Core 2.2 support in the Connector/NET8.0.17 release. As you might know, .NET Core 2.2 is the latest GA release of .NET Core to provide a cross-platform framework that lets you build applications for Windows, Linux and macOS.

Our product, MySQL Connector/NET, is built against .NET Standard 2.0 that allows you to use it as a library in any of the .NET implementations compatible with that version of .NET Standard. For more details related to frameworks compatibility, you can go to the official .NET Standard versions web page. Given this, you can build a .NET Core 2.2 application using MySQL Connector/NET 8.0.17 and take advantage of all the new features and improvements this framework has to offer you.

To use Connector/NET in your .NET Core 2.2 project, simply make a reference to the library. There are two ways of achieving this:

  • First, by using NuGet to download a compatible version automatically.
  • Secondly, by downloading the MySQL Connector/NET source code and building it to ensure the corresponding DLLs are created. Then you can make use of the .NET Standard 2.0 version in your project.

Remember to include the element TargetFramework in your project file and to set the version of .NET Core desired, as shown in the example below:


If you are new to this framework, Microsoft offers a very useful guide to get you started with .NET Core (see Microsoft .NET Core guide).

We hope you find this information useful so you could start using MySQL Connector/NET with the most recent technologies. Your feedback is always welcome and all your comments inspire us to keep improving so that we offer you a product with top quality.

Finally, here are some links that could be useful for you:

We hope to hear from you!

MySQL Connector/NET 8.0.17 has been released

Dear MySQL users,

MySQL Connector/NET 8.0.17 is the fifth version to support Entity Framework Core 2.1 and the sixth general availability release of MySQL Connector/NET to add support for the new X DevAPI, which enables application developers to write code that combines the
strengths of the relational and document models using a modern, NoSQL-like syntax that does not assume previous experience writing traditional SQL.

To learn more about how to write applications using the X DevAPI, see http://dev.mysql.com/doc/x-devapi-userguide/en/index.html. For more information about how the X DevAPI is implemented in Connector/NET, see http://dev.mysql.com/doc/dev/connector-net. NuGet packages provide functionality at a project level. To get the
full set of features available in Connector/NET such as availability in the GAC, integration with Visual Studio’s Entity Framework Designer and integration with MySQL for Visual Studio, installation through the MySQL Installer or the stand-alone MSI is required.

Please note that the X DevAPI requires at least MySQL Server version 8.0 or higher with the X Plugin enabled. For general documentation about how to get started using MySQL as a document store, see http://dev.mysql.com/doc/refman/8.0/en/document-store.html.

To download MySQL Connector/NET 8.0.17, see http://dev.mysql.com/downloads/connector/net/

Installation instructions can be found at https://dev.mysql.com/doc/connector-net/en/connector-net-installation.html

Changes in MySQL Connector/NET 8.0.17 (2019-07-22, General

     * Functionality Added or Changed

     * Bugs Fixed

Functionality Added or Changed

     * Connector/NET supports SSL PEM certificate versions 1, 2,
       and 3 to enable use with the full range of applications
       that generate certificates. (Bug #29756058)

     * Support was added for .NET Core 2.2, which is a
       cross-platform version of .NET for building applications
       that run on Linux, macOS and Windows (see Connector/NET

     * Document Store: The Where() method is deprecated
       (Obsolete attribute applied) and will return a warning
       when called in the following method constructs:
       Find().Where(), Modify().Where(), and Remove().Where().

     * New README.md and CONTRIBUTING.md files now accompany
       MySQL Connector/NET code for compatibility with Git.
       Distribution packages (NuGet, MSI, ZIP) continue to
       include the original README file, but do not include the
       new files.

     * Connector/NET now supports the new utf8mb4_0900_bin
       collation added for the utf8mb4 Unicode character set in
       MySQL 8.0.17. For more information about this collation,
       see Unicode Character Sets

     * Document Store: Connector/NET now supports the OVERLAPS
       and NOT OVERLAPS operators for expressions on JSON arrays
       or objects:
expr OVERLAPS expr
expr NOT OVERLAPS expr

       Suppose that a collection has these contents:
   “_id”: “1”,
   “list”: [1, 4]
 }, {
   “_id”: “2”,
   “list”: [4, 7]

       This operation:
var res = collection.Find(“[1, 2, 3] OVERLAPS $.list”).Fields(“_id”).E

       Should return:
[{ “_id”: “1” }]

       This operation:
var res = collection.Find(“$.list OVERLAPS [4]”).Fields(“_id”).Execute

       Should return:
[{ “_id”: “1” }, { “_id”: “2” }]

       An error occurs if an application uses either operator
       and the server does not support it.

     * Document Store: For index specifications passed to the
       Collection.CreateIndex() method, Connector/NET now
       supports indexing array fields. For example, consider a
       collection with this array:
Session session = MySQLX.GetSession(connString);
Schema schema = session.GetSchema(schemaName);
Collection coll = schema.CreateCollection(collectionName);

var docs = new[]
  new {  _id = 1, name = “John Smith”, emails = [ “john.smith@mycompan
y.com”, “jsmith@php.net”, “jsmith@mail.com” ] }


       A single index field description can contain a new member
       name array that takes a Boolean value. If set to true,
       the field is assumed to contain arrays of elements of the
       given type. In addition, the set of possible index field
       data types (used as values of member type in index field
       descriptions) is extended with type CHAR(N), where the
       length N is mandatory. For example, to create the
       emails_idx index with an array field:
    “{\”fields\”: [{\”field\”: $.emails,
                   \”array\”: true }]}”

       To find an element of the array:
   .Find(“:mail IN $.emails”)
   .Bind(“mail”, “jsmith@php.net”)

     * New support for SSH tunneling enables Connector/NET to
       create secure connections to a remote MySQL server using
       TCP/IP over SSH. With SSH server authorization, an
       application can establish a connection from behind a
       firewall when the MySQL Server port is blocked. The new
       connection-string options (and equivalent class
       properties) for SSH tunneling are supported by both the
       classic MySQL protocol and X Protocol connections.

Bugs Fixed

     * The BouncyCastle assembly was loaded into memory whenever
       a connection attempt was made using any SSL mode type,
       except None. Now the assembly loads only when the SSL
       mode type is VerifyCA or VerifyFull, or when PEM
       certificates are used. (Bug #29611216)

     * Document Store: The MySqlConnection.GetSchema() method
       sometimes returned columns in an unexpected order when
       used with the INFORMATION_SCHEMA.COLUMNS table. This fix
       ensures that returned columns now correspond to the
       ordinal position only. (Bug #29536344)

     * The InvariantCulture property was missing from some data
       types, which created issues during platform migration
       operations. Thanks to Effy Teva for the patch. (Bug
       #29262195, Bug #94045)

     * Connector/NET connections executed SHOW VARIABLES
       unnecessarily. (Bug #28928543, Bug #93202)

     * Connector/NET access to MySQL stopped working after the
       computer hosting the server was started and continued to
       operate uninterrupted for a defined period of time. (Bug
       #26930306, Bug #75604)

On Behalf of Oracle/MySQL Engineering Team
Prashant Tekriwal

Working with SSH Tunneling and SSL PEM Certificates in Connector/NET

Dear MySQL Connector/NET community,

We are proud to announce that version 8.0.17 is introducing support for SSH tunneled connections through the classic MySQL protocol and X Protocol. SSH enables the creation of secure encrypted connections between the local and a remote computer allowing services or components to be accessed, MySQL Server in this case. With SSH tunneling, users can connect to a MySQL Server from behind a firewall when the server port is blocked. The server doesn’t require any additional configuration for this type of connection and continues to work as usual.

Users can also add an extra layer of security by making use of SSL over SSH connections, which brings us to the second announcement. Connector/NET previously included support for SSL connections via PFX certificates, which are exclusive to Windows. However, now the support for SSL PEM certificates is available starting with version 8.0.16. This allows Connector/NET to align with other MySQL products. More importantly, it increases the security of your applications, specially when you are working with .NET Core to expand your deployment to platforms beyond Windows.

Connection Options Overview

Those unfamiliar with Connector/NET and/or the differences between the classic MySQL protocol and the X Protocol, first need to be aware of the different ways to construct a connection/session object with which a connection to a MySQL Server can be established. There are 4 methods available:

  • Connection string: Available in the classic MySQL protocol and X Protocol. For the classic protocol an instance of the MySqlConnection class is created. In the constructor you provide a string containing key-value pairs which represent the connection options. For the X Protocol, call the MySQLX.GetSession method and provide the connection string in the constructor as well.
  • Using a builder object: Available in the classic MySQL protocol and X Protocol. An instance of the MySqlConnectionStringBuilder (classic protocol) or MySqlXConnectionStringBuilder (X Protocol) is created. You assign values to the mentioned object’s properties which resemble the connection options available in the connection string. Once the properties have been set, call the ToString method to get the connection string and simply pass it to the MySqlConnection object or MySQLX.GetSession method.
  • URI-like connection string: Available in the X Protocol only. A URI-like string is provided which starts with the mysqlx identifier. It supports the same connection options available for any other connection method.
  • Using anonymous objects: Available in the X Protocol only. An anonymous object is created having properties that match the name of the properties defined in the MySqlXConnectionStringBuilder class. The object is simply passed to the MySQLX.GetSession static method.

Refer to the Connection Examples section for code snippets on using each method.

Creating SSH Tunneled Connections

SSH Connection Options

New connection options have been introduced to support SSH tunneled connections. The connection options can either be specified in the connection string or by making use of an instance of the MySqlConnectionStringBuilder or MySqlXConnectionStringBuilder class. Find the new connection options and their details below:

Connection OptionDescriptionProperty NameConnection String Options
SSH Host NameThe IP address or name of the SSH server.SshHostNamesshHostName, ssh host name, ssh-host-name
SSH PortThe port of the SSH server.SshPortsshPort, ssh port, ssh-port
SSH User NameThe name of the SSH user to use to make a connection.SshUserNamesshUserName, ssh user name, ssh-user-name
SSH PasswordThe SSH password for the selected user.SshPasswordsshPassword, ssh password, ssh-password
SSH Key FileA path to the SSH key file including the filename and extension.SshKeyFilesshKeyFile, ssh key file, ssh-key-file
SSH Pass PhraseThe pass phrase of the SSH key file (if any).SshPassPhrasesshPassPhrase, ssh pass phrase, ssh-pass-phrase

Initiate an SSH Connection

First, the connection protocol being used must be TCP/IP, note that this is the default connection protocol in Connector/NET. Additional to that, the presence of the SSH User Name and either the SSH Password or SSH Key File options will notify Connector/NET of the user’s intent to make use of an SSH connection. Be sure to specify said options.

It is also necessary to specify the IP address or host name of the SSH Server being accessed. If no SSH Port is specified, the connection will default to the commonly known port 22.

An SSH Password or SSH Pass Phrase can also be provided in the event that they are required by the SSH User Name or SSH Key File connection options respectively.

Finally, set the Server connection option to localhost and Port to the port number the MySQL Server is running at in the SSH server.

Fallback for SSH Connections

Connector/NET includes a fallback mechanism when working with SSH connections. If values are provided to connect using both a SSH Key File and a SSH Password, fallback from the key file to the password will take place in the event that the former attempt fails. Note that the fallback is only enabled whenever the error is detected on the server side, this meaning that if the error is on the client side the user will instead get an exception prior to the connection attempts being made. Causes for errors on the client side can be an invalid key file or an incorrect pass phrase. 

Connection Examples

The following code examples will get you started on creating SSH Tunneled connections:

Example 1
// This is the most basic form of an SSH connection. MySQL port defaults to
// 3306 and SSH Port defaults to 22 since the values are not provided.
// Also, only a password is being used to authenticate to SSH server.
// Connection is being made using a MySqlConnectionStringBuilder object.
var builder = new MySqlConnectionStringBuilder();
builder.UserID = "myUser";
builder.Password = "test";
builder.Server = "localhost";
builder.SshHostName = "";
builder.SshUserName = "mySshUser";
builder.SshPassword = "sshtest";
using (var connection = new MySqlConnection(builder.ConnectionString))
Example 2
// Now the MySQL and SSH ports are being provided.
// Again, only a password is being used to authenticate to SSH server.
// Connection is being made using a connection string.
using (var connection = new MySqlConnection("uid=myUser;password=test;server=localhost;port=3307;sshHostName=;sshUserName=mySshUser;sshPassword=sshtest;sshPort=23"))
Example 3
// Here, a SSH key file with a pass phrase is provided. 
// Connection is being made using an anonymous object.
using (var connection = new MySqlConnection("uid=myUser;password=test;server=localhost;port=3307;sshHostName=;sshUserName=mySshUser;sshKeyFile=C:\\keys\\myOpenSshKeyFile.ppk;sshPassPhrase=sshTest;sshPort=23"))
Example 4
// A pass phrase-less SSH key file and SSH password are both being provided.
// Given that the key file and pass phrase are valid a fallback to SSH 
// password will take place if authentication via SSH key file fails at 
// server side.
// place if a
var builder = new MySqlConnectionStringBuilder();
builder.UserID = "myUser";
builder.Password = "test";
builder.Server = "localhost";
builder.Port = 3307;
builder.SshHostName = "";
builder.SshUserName = "mySshUser";
builder.SshKeyFile = @"C:\keys\noPassPhraseOpenSshKeyFile.ppk";
builder.SshPassword = "sshtest";
using (var connection = new MySqlConnection(builder.ConnectionString))
Example 5
// An X Protocol SSH connection using a URI-like connection string.
using (var session = MySQLX.GetSession("mysqlx://myUser:test@localhost:33060?sshHostName=;sshUserName=mySshUser;sshPassword=sshTest"))
Example 6
// An X Protocol SSH connection using an anonymous object along with
// setting an SSL Mode.
var sessionOptions = {
    UserID = "myUser",
    Password = "test",
    Server = "",
    Port = 3307,
    SshHostName = "",
    SshUserName = "mySshUser",
    SshKeyFile = @"C:\keys\myOpenSshKeyFile.ppk",
    SshPassPhrase = "sshtest",
    SslMode = MySqlSslMode.Required
using (var session = MySQLX.GetSession(sessionOptions))

Refer to the official documentation of Connector/NET for additional details on using SSH tunneling for your applications.

Creating SSL Connections with PEM Certificates

Connector/NET supports multiple levels of SSL encryption through the SSL Mode connection option. The list of allowed SSL encryption values are:

  • None: Do not use SSL.
  • Preferred: Use SSL, if server supports it.
  • Required: Always use SSL. Deny connection if server does not support SSL. Do not perform server certificate validation.
  • VerifyCA: Always use SSL. Validate server SSL certificate, but different host name mismatch.
  • VerifyFull: Always use SSL and perform full certificate validation.

The None, Preferred and Required SSL Modes don’t require the user to provide any certificates. Setting SSL Mode to VerifyCA requires that the SSL CA option is set. Setting SSL Mode to VerifyFull requires that SSL CA, SSL Cert and SSL Key are all set. Both VerifyCA and VerifyFull provide added security by performing various validations on the SSL certificates.

SSL Connection Options

Similar to how SSH tunneling introduced new connection options, a couple of connection options were added to support SSL PEM based connections. In past versions, the SSL CA and CertificateFile options could both be used to specify the path to a PFX certificate. Starting with version 8.0.16, the existing SSL CA option was extended to be used with SSL PEM connections as well. The full list of options relevant for SSL PEM connections can be found below:

Connection OptionDescriptionProperty NameConnection String Options
SSL CASpecifies the path to a certificate file in PEM format (.pem) that contains a list of trusted SSL certificate authorities (CA).SslCasslCa ,  ssl-Ca
SSL CertThe name of the SSL certificate file in PEM format to use for establishing an encrypted connection.SslCertsslCert ,  ssl-Cert
SSL KeyThe name of the SSL key file in PEM format to use for establishing an encrypted connection.SslKeysslKey , ssl-Key
SSL ModeSpecifies the level of security required for SSL connections.sslMode ,  ssl Mode ,  ssl-Mode

As previously mentioned, the SSL CA option is also supported in PFX based SSL connections. The extension of the file referenced in this connection option tells Connector/NET how to process the certificate and in the case of PEM based connections, it will notify Connector/NET to check the SSL Cert and SSL Key options.

Connection Examples

The following code examples will get you started on creating SSL PEM based connections:

Example 1
// Here only the SSL Ca option is required since the SSL Mode is set to VerifyCA.
// The connection is being made using a MySqlConnectionStringBuilder object.
var builder = new MySqlConnectionStringBuilder();
builder.UserID = "myUser";
builder.Password = "test";
builder.Server = "localhost";
builder.SslCa = "ca.pem";
builder.SslMode = MySqlSslMode.VerifyCA; 
using (var connection = new MySqlConnection(builder.ConnectionString))
Example 2
// All SSL options are required since the SSL Mode is set to VerifyFull.
// The connection is being made using a connection string.
using (var connection = new MySqlConnection("uid=myUser;password=test;server=localhost;port=3307;sslMode=VerifyFull;sslCa=ca.pem;sslCert=client-cert.pem;sslKey=client.key.pem"))

SSL PEM connections are also available for the X Protocol. SSL connection options are named similarly in the MySqlXConnectionStringBuilder class, anonymous object and URI-like connection string methods. Feel free to use the one that best adapts to your  needs. 

Additional Information and Useful Links

We really hope that you’ve enjoyed the time invested in getting to know these new features and that they prove useful and a step in the right direction to deliver more robust and secure MySQL based applications.

Your feedback is always welcome, so be sure to provide any comments or report any issues into our forums and dedicated bug page.

Finally, we leave you with the following links which will serve as reference to additional information about the topics discussed in this blog post and with Connector/NET in general. Thank you.