MySQL Connector/NET provider for Entity Framework Core 3.1

Hello MySQL Connector/NET community,

Keeping an ongoing pace to support the latest technologies, we are pleased to announce the latest updates regarding MySQL Connector/NET and Entity Framework Core.

As you may know, Entity Framework Core 3.1 is the latest and long-term support (LTS) release, meaning that it will be supported for at least 3 years. It has a primary goal to polish the EF Core 3.0 version and reintroduces support for .NET Standard 2.0, so it will run on .NET Frameworks versions that support the standard. In our continuous effort to keep up on the latest technologies, we would like to share with you that our latest GA release, Connector/NET 8.0.20, comes with full support for EF Core 3.1.

Let’s have a short demonstration on how to use Connector/NET and EF Core. We are going to use the Code First process to create the database in our server and build up our Entity Model in a Console Application.

Prerequisites:
– Visual Studio 2019
.NET Core 3.1 SDK
MySQL Server
– Connector/NET 8.0.20 (this could be obtained on our site or by using NuGet)

We are going to start by creating a console application and in this case, we are going to do it by using .NET Core CLI:

dotnet new console -o EFCoreSample

If we look into the .csproj file of our application, we can see that the TargetFramework have been set to netcoreapp3.1. Then we need to add our EF Core Connector/NET NuGet package to the project:

dotnet add package MySql.Data.EntityFrameworkCore –-version
8.0.20

So now that we have our console application and the EF Core Connector/NET package installed, we can start writing our context and entity classes. Create a class called Model.cs in the project directory with the following code:

using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using MySql.Data.EntityFrameworkCore.DataAnnotations;

namespace EFCoreSample
{
  public class LibraryContext : DbContext
  {
    public DbSet<Book> Book { get; set; }
    public DbSet<Publisher> Publisher { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder options)
        => options.UseMySQL("server=localhost;database=efcoresample;user=efcore;password=");

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
      base.OnModelCreating(modelBuilder);

      modelBuilder.Entity<Publisher>(entity =>
      {
        entity.HasKey(e => e.ID);
        entity.Property(e => e.Name).IsRequired();
      });

      modelBuilder.Entity<Book>(entity =>
      {
        entity.HasKey(e => e.ISBN);
        entity.Property(e => e.Title).IsRequired();
        entity.HasOne(d => d.Publisher)
          .WithMany(p => p.Books);
      });
    }
  }

  [MySqlCollation("latin1_spanish_ci")]
  public class Book
  {
    [MySqlCharset("latin1")]
    public string ISBN { get; set; }

    public string Title { get; set; }
    public string Author { get; set; }
    public string Language { get; set; }
    public int Pages { get; set; }
    public virtual Publisher Publisher { get; set; }
  }

  public class Publisher
  {
    public int ID { get; set; }
    public string Name { get; set; }
    public virtual ICollection<Book> Books { get; set; }
  }
}

Now that we have our context and entity classes set up, we can start using our model the way we want to, in this example we are going to insert a couple of records and then print them in screen. On the main class of our project (Program.cs) we are going to add two methods, one to insert data and another to print it:

using System;
using System.Text;
using Microsoft.EntityFrameworkCore;

namespace EFCoreSample
{
  class Program
  {
    static void Main(string[] args)
    {
      InsertData();
      PrintData();
      Console.ReadKey();
    }

    private static void InsertData()
    {
      using (var context = new LibraryContext())
      {
        // Creates the database if not exists
        context.Database.EnsureCreated();

        // Adds a publisher
        var publisher = new Publisher
        {
          Name = "Mariner Books"
        };
        context.Publisher.Add(publisher);

        // Adds some books
        context.Book.Add(new Book
        {
          ISBN = "978-0544003415",
          Title = "The Lord of the Rings",
          Author = "J.R.R. Tolkien",
          Language = "English",
          Pages = 1216,
          Publisher = publisher
        });
        context.Book.Add(new Book
        {
          ISBN = "978-0547247762",
          Title = "The Sealed Letter",
          Author = "Emma Donoghue",
          Language = "English",
          Pages = 416,
          Publisher = publisher
        });

        // Saves changes
        context.SaveChanges();
      }
    }

    private static void PrintData()
    {
      // Gets and prints all books in database
      using (var context = new LibraryContext())
      {
        var books = context.Book.Include(p => p.Publisher);
        foreach (var book in books)
        {
          var data = new StringBuilder();
          data.AppendLine($"ISBN: {book.ISBN}");
          data.AppendLine($"Title: {book.Title}");
          data.AppendLine($"Publisher: {book.Publisher.Name}");
          Console.WriteLine(data.ToString());
        }
      }
    }
  }
}

And that’s it! A quick look on how to build an EF Core 3.1 application using MySQL Connector/NET as the provider. This is just a small demonstration of what ypu can do with EF Core. There are many features in EF Core to use and we are pleased to tell you that Connector/NET has full support for them.

We hope you find this information useful to 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/J 5.1.49 GA has been released

Dear MySQL Users,

MySQL Connector/J 5.1.49, a maintenance release of the production 5.1
branch, has been released. Connector/J is the Type-IV pure-Java JDBC
driver for MySQL.

MySQL Connector/J is available in source and binary form from the
Connector/J download pages at
http://dev.mysql.com/downloads/connector/j/5.1.html
and mirror sites as well as Maven repositories.

MySQL Connector/J (Commercial) is available for download on the My Oracle
Support (MOS) website. This release will shortly be available on
eDelivery (OSDC).

As always, we recommend that you check the “CHANGES” file in the
download archive to be aware of changes in behavior that might affect
your application.

MySQL Connector/J 5.1.49 includes the following general bug fixes and
improvements, also available in more detail on
https://dev.mysql.com/doc/relnotes/connector-j/5.1/en/news-5-1-49.html

Changes in MySQL Connector/J 5.1.49 (2020-04-29, General
Availability)

   Version 5.1.49 is a maintenance release of the production 5.1
   branch. It is suitable for use with MySQL Server versions
   5.6, 5.7, and 8.0. It supports the Java Database Connectivity
   (JDBC) 4.2 API.

     * Functionality Added or Changed

     * Bugs Fixed

Functionality Added or Changed

     * Default value of the connection property
       allowLoadLocalInfile has been changed to false.
       Applications that use the LOAD DATA LOCAL INFILE
       (https://dev.mysql.com/doc/refman/8.0/en/load-data.html)
       statement on MySQL Servers need to set this property to
       true explicitly. (Bug #29261254, Bug #30866178)

     * The allowable versions of TLS protocol used for
       connecting to the server, when no restrictions have been
       set using the connection properties enabledTLSProtocols,
       have been changed to:

          + TLSv1, TLSv1.1, and TLSv1.2 for MySQL Community
            Servers 8.0, 5.7.28 and later, and 5.6.46 and later,
            and for commercial versions of MySQL Server 5.6,
            5.7, and 8.0.

          + TLSv1 and TLSv1.1 for all other versions of MySQL
            Servers.

     * The following third-party libraries have been removed
       from the distribution bundles for Connector/J:

          + C3P0 (required for building Connector/J from source)

          + JBoss common JDBC wrapper (required for building
            Connector/J from source)

          + Simple Logging Facade API (required for using the
            logging capabilities provided by the default
            implementation of org.slf4j.Logger.Slf4JLogger by
            Connector/J, and for building Connector/J from
            source)
       Users who need those libraries have to obtain them on
       their own. See Installing Connector/J from a Binary
       Distribution
(https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-binary-installation.html)
       and Installing from Source
(https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-installing-source.html)
       for details.

Bugs Fixed


     * When trying to set a parameter for a PreparedStatement
       using the method
       PreparedStatement.setObject(parameterIndex, “false”,
       Types.BOOLEAN), the value was set to true instead of
       false. (Bug #30911870, Bug #98237)

     * In line with good XML practices, DTD processing has been
       disabled for Connector/J’s MySQL Fabric XML parser. (Bug
       #30657312)

     * Methods of the ResultSetUtil class that are no longer
       used in Connector/J 5.1 have been removed. (Bug
       #30636056)

     * For some prepared statements, calling getMetaData() on
       them resulted in an Incorrect DATE error, even when no
       DATE values were involved. This was due to some recent
       changes on the MySQL Server, to which this patch adjusts
       Connector/J. (Bug #30151808, Bug #96442)
       References: See also: Bug #29025656, Bug #28940878.

     * When working with a load balancing setup, if the
       connection property loadBalanceStrategy was set to
       bestResponseTime and connections to all the hosts in the
       original setup failed, Connector/J hung, even if there
       were actually newly-added hosts available. This was
       because Connector/J mishandled the host whitelist, and
       this patch corrects the problem. (Bug #23143279)

     * Inserting values in batch using a PreparedStatement
       failed for an INSERT …VALUE
       (https://dev.mysql.com/doc/refman/8.0/en/insert.html)
       statement but worked for an INSERT … VALUES
       (https://dev.mysql.com/doc/refman/8.0/en/insert.html)
       statement, while they are synonymous for MySQL. (Bug
       #21181501, Bug #77183)


On Behalf of Oracle/MySQL Release Engineering Team,
Sreedhar S

MySQL Connector/Python 8.0.20 has been released

Dear MySQL users,

MySQL Connector/Python 8.0.20 is the latest GA release version of the
MySQL Connector Python 8.0 series. The X DevAPI 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/

For more information about how the X DevAPI is implemented in MySQL
Connector/Python, and its usage, see

  http://dev.mysql.com/doc/dev/connector-python

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/Python 8.0.20, see the “General Availability
(GA) Releases” tab at

  http://dev.mysql.com/downloads/connector/python/

Enjoy!

==============================================================================

Changes in MySQL Connector/Python 8.0.20 (2020-04-27, General Availability)

Functionality Added or Changed

 * For X DevAPI applications, when creating a new
   connection, if the connection data contains several
   target hosts that have no explicit priority assigned, the
   behavior of the failover logic now is the same as if all
   those target hosts have the same priority. That is, the
   next candidate for making a connection is chosen randomly
   from the remaining available hosts. Alternatively, the
   new priority attribute optionally sets the priority for
   each host. If two hosts have the same priority then one
   is chosen at random.

Bugs Fixed

 * The fetchmany() method failed to function properly when
   the last fetch was not a full batch; and would hang.
   Thanks to Bruce Feng for the patch.
   (Bug#30608703, Bug#97830)

On Behalf of Oracle/MySQL Engineering Team
Kent Boortz

MySQL Connector/C++ 8.0.20 has been released

Dear MySQL users,

MySQL Connector/C++ 8.0.20 is a new release version of the MySQL
Connector/C++ 8.0 series.

Connector/C++ 8.0 can be used to access MySQL implementing Document
Store or in a traditional way, using SQL queries. It allows writing
both C++ and plain C applications using X DevAPI and X DevAPI for C.
It also supports the legacy API of Connector/C++ 1.1 based on JDBC4.

To learn more about how to write applications using X DevAPI, see
“X DevAPI User Guide” at

https://dev.mysql.com/doc/x-devapi-userguide/en/

See also “X DevAPI Reference” at

https://dev.mysql.com/doc/dev/connector-cpp/devapi_ref.html

and “X DevAPI for C Reference” at

https://dev.mysql.com/doc/dev/connector-cpp/xapi_ref.html

For generic information on using Connector/C++ 8.0, see

https://dev.mysql.com/doc/dev/connector-cpp/

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/C++ 8.0.20, see the “General Availability (GA)
Releases” tab at

https://dev.mysql.com/downloads/connector/cpp/

Changes in MySQL Connector/C++ 8.0.20 (2020-04-27, General Availability)

Connection Management Notes

     * For connections made using X Plugin, Connector/C++ now
       provides control over the use of compression to minimize
       the number of bytes sent over connections to the server.
       Connection URIs and SessionSettings objects permit
       explicitly specifying a compression option:

          + URI strings permit a compression option with
            permitted values of DISABLED, PREFERRED, and
            REQUIRED (not case-sensitive). Examples:
            mysqlx://user:password@host:port/db?compression=DISABLED
            mysqlx://user:password@host:port/db?compression=PREFERRED
            mysqlx://user:password@host:port/db?compression=REQUIRED

          + SessionSettings object permit a
            SessionOption::COMPRESSION option with permitted
            values of CompressionMode::DISABLED,
            CompressionMode::PREFERRED, and
            CompressionMode::REQUIRED. Example:
            mysqlx::Session sess(SessionOption::PORT, “user_name”,
                                 SessionOption::USER, “password”,
                                 SessionOption::COMPRESSION,
                                 CompressionMode::PREFERRED);

       These rules apply:

          + If compression is disabled, the connection is
            uncompressed.

          + If compression is preferred, Connector/C++
            negotiates with the server to find a compression
            algorithm supported in common on the server and
            client sides. If no common algorithm is available,
            the connection is uncompressed.

          + If compression is required, compression algorithm
            negotiation occurs as with compression preferred. If
            no common algorithm is available, the connection
            terminates with an error.
       To avoid CPU inefficiency, data packets are not
       compressed even when compression is enabled unless they
       exceed a threshold size (currently 1000 bytes; this is
       subject to change).
       See also Connection Compression with X Plugin
       (https://dev.mysql.com/doc/refman/8.0/en/x-plugin-connection-compression.html).


Packaging Notes

     * Previously, Connector/C++ binary distributions were
       compatible with projects built using MSVC 2019 (using
       either dynamic or static connector libraries) or MSVC
       2017 (using dynamic connector libraries only). Binary
       distributions now are also compatible with MSVC 2017
       using the static X DevAPI connector library. This means
       that binary distributions are fully compatible with MSVC
       2019, and fully compatible with MSVC 2017 with the
       exception of the static legacy (JDBC) connector library.


Bugs Fixed

     * For connections made using X Plugin, the last byte was
       removed from DATETIME values fetched as raw bytes. (Bug
       #30838230)

     * In X DevAPI expressions, Connector/C++ treated the JSON
       ->> operator the same as ->, rather than applying an
       additional JSON_UNQUOTE() operation. (Bug #29870832)

     * Comparison of JSON values from query results failed due
       to an extra \0 character erroneously being added to the
       end of such values. (Bug #29847865)

     * For connections made using X Plugin, warnings sent
       following result sets were not captured, and were thus
       unavailable to getWarnings(). (Bug #28047970)

On Behalf of Oracle/MySQL Release Engineering Team,
Hery Ramilison

MySQL Connector/ODBC 8.0.20 has been released

Dear MySQL users,

MySQL Connector/ODBC 8.0.20 is a new version in the MySQL Connector/ODBC
8.0 series, the ODBC driver for the MySQL Server.

The available downloads include both a Unicode driver and an ANSI driver
based on the same modern codebase. Please select the driver type you
need based on the type of your application – Unicode or ANSI.
Server-side prepared statements are enabled by default. It is suitable
for use with the latest MySQL server version 8.0.

This release of the MySQL ODBC driver is conforming to the ODBC 3.8
specification. It contains implementations of key 3.8 features,
including self-identification as a ODBC 3.8 driver, streaming of out for
binary types only), and support of the SQL_ATTR_RESET_CONNECTION
connection attribute (for the Unicode driver only).

The release is now available in source and binary form for a number of
platforms from our download pages at

https://dev.mysql.com/downloads/connector/odbc/

For information on installing, please see the documentation at

https://dev.mysql.com/doc/connector-odbc/en/connector-odbc-installation.html

Enjoy and thanks for the support!

================================================================

Changes in MySQL Connector/ODBC 8.0.20 (2020-04-27, General Availability)

  • Functionality Added or Changed
  • Bugs Fixed

Functionality Added or Changed

  • On Debian, DEB packages are now released instead of TGZ
    files. The file base names are mysql-connector-odbc-*
    (driver package) and mysql-connector-odbc-setup (setup
    package). The setup package contains the GUI
    configuration widget library (libmyodbc8S.so) and depends
    on the driver package. The driver package depends on the
    unixODBC libraries (libodbc, libodbcinst); and does not
    conflict with the official Debian package (libmyoodbc).

Bugs Fixed

  • When using SQL_C_WCHAR with SQLGetData, binary data was
    not returned correctly as its hexacecimal representation.
    Related, using SQL_C_CHAR with SQLGetData did return
    binary data as hex. (Bug #28864788, Bug #92429)
  • When binding an SQL_BIT type column to the SQL_C_CHAR
    type, SQLFetchScroll would return the values as an
    integer instead of a char. (Bug #28484784, Bug #91904)

On Behalf of Oracle/MySQL Engineering Team
Prashant Tekriwal

MySQL Connector/Node.js 8.0.20 has been released

Dear MySQL users,

MySQL Connector/Node.js is a new Node.js driver for use with the X
DevAPI. This release, version 8.0.20, is a maintenance release of the
MySQL Connector/Node.js 8.0 series.

The X DevAPI 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.

MySQL Connector/Node.js can be downloaded through npm (see
https://www.npmjs.com/package/@mysql/xdevapi for details) or from
https://dev.mysql.com/downloads/connector/nodejs/.

To learn more about how to write applications using the X DevAPI, see
http://dev.mysql.com/doc/x-devapi-userguide/en/.
For more information about how the X DevAPI is implemented in MySQL
Connector/Node.js, and its usage, see
http://dev.mysql.com/doc/dev/connector-nodejs/.

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.

Changes in MySQL Connector/Node.js 8.0.20 (2020-04-27, General Availability)

Functionality Added or Changed

     * Added two new connection options that evaluate during the
       TLS handshake to restrict the negotiated TLS protocols
       and ciphers; along with those configured on the server
       that can further restrict the final choices. These new
       options are tls-versions to define the allowed TLS
       protocol versions, and tls-ciphersuites for the allowed
       cipher suites. These definitions are comma-separated, and
       accepted by the getSession() and getClient() methods.
       tls-versions: accepts one or more of the following:
       TLSv1, TLSv1.1, TLSv1.2, and TLSv1.3. Other values
       generate an error.
       tls-ciphersuites: accepts IANA cipher suite names, as
       listed on IANA’s TLS Cipher Suites
(https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4)
       page. Unsupported or unknown values are ignored.
       Example usage demonstrating both plain JavaScript and
       JSON configuration object formats:
# tls versions:
mysqlx.getSession(‘mysqlx://root@localhost?tls-versions=[TLSv1,TLSv1.1
,TLSv1.2,TLSv1.3]’)

mysqlx.getSession({ user: ‘root’, tls: { versions: [‘TLSv1’, ‘TLSv1.1’
, ‘TLSv1.2’, ‘TLSv1.3’] } })

# tls ciphersuites
mysqlx.getSession(‘mysqlx://root@localhost?tls-ciphersuites=[DHE-RSA-A
ES128-GCM-SHA256,DHE-RSA-AES256-SHA256]’)

mysqlx.getSession({ user: ‘root’, tls: { ciphersuites: [‘DHE-RSA-AES12
8-GCM-SHA256′, ‘DHE-RSA-AES256-SHA256’] } })

     * For X DevAPI applications, when creating a new
       connection, if the connection data contains several
       target hosts that have no explicit priority assigned, the
       behavior of the failover logic now is the same as if all
       those target hosts have the same priority. That is, the
       next candidate for making a connection is chosen randomly
       from the remaining available hosts. If two hosts have the
       same priority then one is chosen at random.

On Behalf of MySQL/ORACLE RE Team
Gipson Pulla

MySQL Connector/J 8.0.20 has been released

Dear MySQL users,

MySQL Connector/J 8.0.20 is the latest General Availability release of
the MySQL Connector/J 8.0 series.  It is suitable for use with MySQL
Server versions 8.0, 5.7, and 5.6.  It supports the Java Database
Connectivity (JDBC) 4.2 API, and implements the X DevAPI.

This release includes the following new features and changes, also
described in more detail on

https://dev.mysql.com/doc/relnotes/connector-j/8.0/en/news-8-0-20.html

As always, we recommend that you check the “CHANGES” file in the
download archive to be aware of changes in behavior that might affect
your application.

To download MySQL Connector/J 8.0.20 GA, see the “General Availability
(GA) Releases” tab at http://dev.mysql.com/downloads/connector/j/

Enjoy!

Changes in MySQL Connector/J 8.0.20 (2020-04-27, General Availability)

* Functionality Added or Changed

* Bugs Fixed

Functionality Added or Changed

* X DevAPI: Connector/J now supports data compression for X Protocol
connections (https://dev.mysql.com/doc/refman/8.0/en/x-plugin-connection- compression.html). See Connection Compression Using X DevAPI (https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-connection-compression-xdevapi.html) for details.

* A new method, getElapsedTime(), has been added to
Connector/J ‘s implementation of the Statement interface,
to expose the elapsed time for a query. Thanks to Matti
Sillanpää for contributing the code. (Bug #30570249, Bug
#97714)

Bugs Fixed

* When a custom Calendar was used in the setDate method for
a PreparedStatement, it was being used by subsequent
calls of the same method that did not use the same
calendar, resulting in the wrong date being set. It was
because the SimpleDateFormat object created internally
with the custom calendar was cached and reused. With this
fix, the object is no longer cached. (Bug #30877755)

* Setting the connection property clientInfoProvider
without using the fully qualified class name for
ClientInfoProviderSP caused a NullPointerException. This
was due to some wrong exception handling, which has been
corrected by this fix. (Bug #30832513)

* Authentication failed when a client tried to connect to a
server that used Windows Authentication Plugin and the
Kerberos protocol. It was because the implementation of
the NativeAuthenticationProvider class by Connector/J did
not interact correctly with a custom-made Kerberos
authentication plugin, and this patch fixes the issue.
(Bug #30805426)

* Methods from the ResultSetUtil class are no longer used
in Connector/J 8.0.20; the class has therefore been
removed. (Bug #30636056)

* A NullPointerException was returned when the connection
had cacheResultSetMetadata=true and a query containing
any SET statements was executed. This fix corrects the
issue by adding the missing variable assignment, and also
a null check. (Bug #30584907, Bug #97757)

* A DataConversionException was thrown when an application
tried to store a string starting with “d.” [d was any
digit] into a VARCHAR column. It was due to a parsing
error in the AbstractNumericValueFactory, which has been
fixed by this patch. Thanks to Nick Pollett for
contributing the code. (Bug #30570721, Bug #97724)

* When creating a Statement, the specification for the
resultSetType parameter was not honored, so that the
ResultSet type was always set to
ResultSet.TYPE_FORWARD_ONLY. With this fix, the
resultSetType parameter is now honored. Also, type
validation has been added so that calling the methods
beforeFirst, afterLast, first, last, absolute, relative,
or previous results in an exception if the ResultSet type
is ResultSet.TYPE_FORWARD_ONLY. (Bug #30474158)

* When a Calendar was not used, a java.sql.Date value could
not always be stored into and then retrieved from a MySQL
server consistently. It was because Connector/J always
converted a Date value to the server’s time zone when
storing it on the server as a MySQL DATE; but since a
MySQL DATE does not have any time value, the hour,
minute, and second parts of the original date was
effectively lost. If the converted value is one day ahead
of or behind the original value, when the value was
retrieved through Connector/J and converted back to the
local time zone, there was no time value for adjusting
the date back to its original value, resulting in a
one-day error. With this fix, any Date value is converted
to MySQL DATE value using the JVM’s time zone, so that
the value is always consistent when being stored and then
read back.
Also, the cacheDefaultTimezone connection property,
previously removed from Connector/J 8.0, has now been
restored so that when it is set to false, Connector/J
becomes aware of the time zone changes of the JVM during
runtime and converts dates with the updated time zone.
(Bug #28125069, Bug #91112)

On Behalf of MySQL Release Engineering Team,
Surabhi Bhat

MySQL Connector/NET 8.0.20 has been released

Dear MySQL users,

MySQL Connector/NET 8.0.20 is the latest General Availability release of
the MySQL Connector/NET 8.0 series. This version supports .NET Core 3.1
and the 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.20, 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.20 (2020-04-27, General
Availability)

    * Functionality Added or Changed

    * Bugs Fixed

Functionality Added or Changed

    * Connector/NET now supports Entity Framework Core 3.1.1 on
      all platforms with NET Standard 2.0 support. Microsoft
      Entity Framework Core 3.1.1 is not compatible with the
      previous versions of EF Core and those previous versions
      (2.1, 2.0, 1.1) are not supported by this release of
      Connector/NET (see Entity Framework Core Support
(https://dev.mysql.com/doc/connector-net/en/connector-net-entityframework-core.html)).
      In addition, the MySql.Data.EntityFrameworkCore.Design
      NuGet package is deprecated and the functionality
      provided by that package now is merged with the
      MySql.Data.EntityFrameworkCore package.

    * Connector/NET now provides compression of X Protocol
      payload data, which can be configured using the new
      Compression connection option. The option is set to
      preferred mode by default to compress the payload data if
      the MySQL server instance also supports compression. For
      a description of each option value, see Options for X
      Protocol Only
(https://dev.mysql.com/doc/connector-net/en/connector-net-8-0-connection-options.html#connector-net-8-0-connection-options-xprotocol).

    * Document Store: Connector/NET now provides JSON schema
      validation for a collection to enforce a certain
      structure that documents must adhere to before they are
      permitted to be inserted or updated. Schema validation is
      performed by the server, which returns an error message
      if a document in a collection does not match the schema
      definition or if the server does not support validation.
      The existing Schema.CreateCollection method now is
      overloaded and can be used to pass a
      CreateCollectionOptions object with a schema definition
      to a MySQL server. The ReuseExistingObject parameter of
      the original method is set as an option within
      CreateCollectionOptions when using the new overloaded
      method. The level of enforcement (off or strict, strict
      by default) and schema definition are specified using the
      validation option, for example:
var collOptions = CreateCollectionOptions() {
    reuseExistingObject = false,
    validation = Validation() {
        level = ValidationLevel.Strict,
        schema = “{\”id\”: \“http://json-schema.org/geo\”,”
                        + “\”$schema\”: \“http://json-schema.org/draft-06/schema# \”,”
                        +               ” \”description\”: \”A geographical coordinate\”, ”
                        +               ” \”type\”: \”object\”,”
                        +               ” \”properties\”: {”
                        +                    ” \”latitude\”: {”
                        +                         ” \”type\”: \”number\””
                        +                    ” },”
                        +                      ” \”longitude\”: {”
                        +                          ” \”type\”: \”number\””
                        +                     ” }”
                        +                ” },”
                        +                ” \”required\”: [\”latitude\”, \”longitude\”]”
                        +  ” }”
             }
};

var coll = schema.CreateCollection(“longlang”, collOptions);
            In addition, a new method permits the schema validation
            of an existing collection to be reset. The
            Schema.ModifyCollection method passes a
            ModifyCollectionOptions object to the server. The
            validation collection option must include either a
             modified level value or schema value (or both), for
            example:
var collOptions = ModifyCollectionOptions() {
    validation = Validation() {
        level = ValidationLevel.Off
            }
};

var coll = schema.ModifyCollection(“longlang”, collOptions);
           The ReuseExistingObject option is not supported for
           modifications and returns an error message if it is used.

Bugs Fixed

    * A connection made to a named server with multiple DNS
      entries pointing to different IP addresses for the same
      server generated an exception. Now, only the first
      element is returned when multiple elements are found.
      (Bug #30970949, Bug #97448)

    * The MySQL.Data NuGet package for Connector/NET 8.0.19
      included an unsigned version of Ubiety.Dns.Core.dll,
      which produced an exception when loaded. (Bug #30798305,
      Bug #98204)

    * Scaffolding a MySQL database with EF Core 3.0 was not
      implemented by Connector/NET and the connector returned
      an exception in response to its use. Support for EF Core
      3.1.1 in this release adds scaffolding capabilities. (Bug
      #30677382, Bug #98011)

    * The get_info method was not included in any of the Entity
      Framework Core versions (1.1, 2.0, and 2.1) that
      Connector/NET supported. Connector/NET now supports EF
      Core 3.1.1 and implements the
      MySql.Data.EntityFrameworkCore.Infrastructure.MySQLOption
      sExtension.Internal.get_info method. (Bug #30347893, Bug
      #96990)

    * The MySqlDbType.JSON type when used as a parameter in a
      prepared statement produced code errors. Connector/NET
      now interprets MySqlDbType.JSON as MySqlDbType.VarChar.
      No code changes are required to specify a JSON column.
      (Bug #29959124, Bug #95984)

    * Blank spaces mixed with values in the IN() list of a
      SELECT statement generated an error. (Bug #29838254)

    * An attempt to read the record of a model class defined to
      correspond to a MySQL table with a property of type bool?
      (nullable Boolean), using the EF Core database context,
      returned an error message. (Bug #29833103, Bug #93028)

    * Access to the MySqlDataReader object was restricted when
      the parent MySqlCommand object was closed. This fix
      modifies MySqlCommand.Dispose() to no longer call the
      ResetReader method. (Bug #27441433, Bug #89159)

On Behalf of MySQL Release Engineering Team,
Tvarita Jain

Rethinking Result Sets in Connector/Node.js

It used to be the case where, in order to actually process data retrieved from the database using Connector/Node.js, you would have to resort to an API that required the use of both JavaScript callbacks and Promises. This was meant to provide more flexibility and control to the application developer and at the same time decrease the chance of buffering data unnecessarily. However this wasn’t useful for 99% of the use-cases and made simple tasks a little bit cumbersome. Also, the fact that it required using two different asynchronous constructs made it a little bit harder to grasp.

To make matters worse, in order to consume operational metadata about the columns in the result set, you would have to provide an additional callback, making the whole thing spiral a bit out of control, particularly when there were multiple result sets involved. In that case, you needed to create a shared context between the two functions in order to map data and metadata for each column in each result set.

Continue reading

MySQL Connector/C++ 8.0.19 has been released

Dear MySQL users,

MySQL Connector/C++ 8.0.19 is a new release version of the MySQL
Connector/C++ 8.0 series.

Connector/C++ 8.0 can be used to access MySQL implementing Document
Store or in a traditional way, using SQL queries. It allows writing
both C++ and plain C applications using X DevAPI and X DevAPI for C.
It also supports the legacy API of Connector/C++ 1.1 based on JDBC4.

To learn more about how to write applications using X DevAPI, see
“X DevAPI User Guide” at

https://dev.mysql.com/doc/x-devapi-userguide/en/

See also “X DevAPI Reference” at

https://dev.mysql.com/doc/dev/connector-cpp/devapi_ref.html

and “X DevAPI for C Reference” at

https://dev.mysql.com/doc/dev/connector-cpp/xapi_ref.html

For generic information on using Connector/C++ 8.0, see

https://dev.mysql.com/doc/dev/connector-cpp/

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/C++ 8.0.19, see the “General Availability (GA)
Releases” tab at

https://dev.mysql.com/downloads/connector/cpp/


==================================================

Changes in MySQL Connector/C++ 8.0.19 (2020-01-13, General Availability)

* Error Handling

* Legacy (JDBC API) Notes

* Packaging Notes

* X DevAPI Notes

* Functionality Added or Changed

* Bugs Fixed

Error Handling

* If an application tries to obtain a result set from a statement that does not produce one, an exception occurs. For applications that do not catch such exceptions, Connector/C++ now produces a more informative error message to indicate why the exception occurred. (Bug #28591814, Bug #92263)

Legacy (JDBC API) Notes

* For applications that use the legacy JDBC API (that is, not made using X DevAPI or X DevAPI for C), it is now possible when creating a new session to specify multiple hosts to be tried until a successful connection is established. A list of hosts can be given in the session creation options. The new OPT_MULTI_HOST option is disabled by default for backward compatibility, but if enabled in the ConnectionOptionsMap parameter passed to connect() calls, it permits other map parameters to specify multiple hosts. Examples:

sql::ConnectOptionsMap opts;
opts[“hostName”]=”host1,host2:13001,localhost:13000″;
opts[“schema”]=”test”; opts[“OPT_MULTI_HOST”] = true;
opts[“userName”]=”user”; opts[“password”]=”password”;
driver->connect(opts);

sql::ConnectOptionsMap opts; opts[“hostName”]=”tcp://host1,host2:13001,localhost:13000/test”; opts[“OPT_MULTI_HOST”] = true;
opts[“userName”]=”user”; opts[“password”]=”password”;
driver->connect(opts);

sql::ConnectOptionsMap opts; opts[“hostName”]=”mysql://host1,host2:13001,localhost:13000/test”; opts[“OPT_MULTI_HOST”] = true;
opts[“userName”]=”user”;
opts[“password”]=”password”;
driver->connect(opts);

Port values are host specific. If a host is specified without a port number, the default port is used. These rules apply:

+ If OPT_MULTI_HOST is disabled and multiple hosts are specified, an error occurs.

+ If OPT_MULTI_HOST is disabled and a single host that resolves to multiple hosts is specified, the first host is used for backward compatibility.

+ If OPT_MULTI_HOST is enabled and multiple hosts are specified, one of them is randomly chosen as the connection target. If the target fails, another host is randomly chosen from those that remain. If all targets fail, an error occurs.

+ The hostName parameter can accept a URI that contains a list of comma-separated hosts. The URI scheme can be mysql://, which works like tcp://. The URI scheme can also be omitted, so the parameter can be a list of comma-separated hosts.

+ The connect() syntax that takes URI, user, and password parameters does not permit multiple hosts because in that case OPT_MULTI_HOST is disabled.

Packaging Notes

* Connector/C++ now is compatible with MSVC 2019, while retaining compatibility with MSVC 2017:

+ Previously, Connector/C++ binary distributions were compatible with projects built using MSVC 2017 or 2015. Binary distributions now are compatible with projects built using MSVC 2019 (using either dynamic or static connector libraries) or MSVC 2017 (using dynamic connector libraries). Building using MSVC 2015 might work, but is not supported.

+ Previously, Connector/C++ source distributions could be built using MSVC 2017 or 2015. Source distributions now can be built using MSVC 2019 or 2017. Building using MSVC 2015 might work, but is not supported.

+ Previously, the MSI installer accepted the Visual C++ Redistributable for Visual Studio 2017 or 2015. The MSI installer now accepts the Visual C++ Redistributable for Visual Studio 2019 or 2017.

X DevAPI Notes

* For applications that use X DevAPI or X DevAPI for C, Connector/C++ now provides options that enable specifying the permitted TLS protocols and ciphersuites for TLS connection negotiation:

+ TLS protocols must be chosen from this list: TLSv1, TLSv1.1, TLSv1.2, TLSv1.3. (TLSv1.3 requires that both the server and Connector/C++ be compiled with OpenSSL 1.1.1 or higher.)

+ Ciphersuite values must be IANA ciphersuite names. TLS protocols and ciphersuites now may be specified in these contexts:

+ Connection strings permit tls-versions and tls-ciphersuites options. The tls-versions value is a list of one or more comma-separated TLS protocol versions. The tls-ciphersuites value is a list of one or more comma-separated ciphersuite names. Examples:
…?tls-versions=[TLSv1.3]&…
…?tls-versions=[TLSv1.2,TLSv1.3]&…
…?tls-ciphersuites=[
TLS_DHE_PSK_WITH_AES_128_GCM_SHA256, TLS_CHACHA20_POLY1305_SHA256
]&…

+ SessionSettings objects permit TLS_VERSIONS and TLS_CIPHERSUITES options. Each value is either a string containing one or more comma-separated items or a container with strings (that is, any type that can be iterated with a loop that yields string values).
Example of single string values:
Session s(…,
TLS_VERSIONS, “TLSv1.2,TLSv1.3”,
TLS_CIPHERSUITES, “TLS_DHE_PSK_WITH_AES_128_GCM_SHA256,TLS_CHACHA20_POLY1305_SHA256” ,
…);
Example of string container values:
std::list<std::string> tls_versions = {
“TLSv1.2”,
“TLSv1.3”
};

std::list<std::string> ciphers = {
“TLS_DHE_PSK_WITH_AES_128_GCM_SHA256”, “TLS_CHACHA20_POLY1305_SHA256”
};

Session s(…,
TLS_VERSIONS, tls_versions
TLS_CIPHERSUITES, ciphers,
…);

Session s(…,
TLS_VERSIONS, std::vector{“TLSv1.2″,”TLSv1.3”},
TLS_CIPHERSUITES, std::vector{“TLS_DHE_PSK_WITH_AES_128_GCM_SHA256”, “TLS_CHACHA20_POLY1305_SHA256”},
…);

+ mysqlx_session_option_set() and friends permit MYSQLX_OPT_TLS_VERSIONS and MYSQLX_OPT_TLS_CIPHERSUITES session option constants, together with the corresponding OPT_TLS_VERSIONS() and OPT_TLS_CIPHERSUITES() macros. MYSQLX_OPT_TLS_VERSIONS and MYSQLX_OPT_TLS_CIPHERSUITES accept a string containing one or more comma-separated items. Examples:
mysqlx_session_option_set(opts, …,
OPT_TLS_VERSIONS(“TLSv1.2,TLSv1.3”),
OPT_TLS_CIPHERSUITES( “TLS_DHE_PSK_WITH_AES_128_GCM_SHA256,TLS_CHACHA20_POLY1305_SHA256”
),
…)

For more information about TLS protocols and ciphersuites in MySQL, see Encrypted Connection TLS Protocols and Ciphers (https://dev.mysql.com/doc/refman/8.0/en/encrypted-connection-protocols-ciphers.html). (Bug #28964583, Bug #93299)

* For X DevAPI or X DevAPI for C, when creating a new connection (given by a connection string or other means), if the connection data contains several target hosts that have no explicit priority assigned, the behavior of the failover logic now is the same as if all those target hosts have the same priority. That is, the next candidate for making a connection is chosen randomly from the remaining available hosts. This is a change from previous behavior, where hosts with no explicit priority were assigned implicit decreasing priorities and tried in the same order as listed in the connection data.

Functionality Added or Changed

* Connector/C++ now supports the use of DNS SRV records to specify multiple hosts:

+ Session and session-pool creation accepts a URI scheme of mysqlx+srv:// that enables the DNS SRV feature in connect strings. Example: mysqlx+srv://example.com/db?options

+ For X DevAPI, mysqlx::Session objects permit a SessionOption::DNS_SRV entry to enable use of a DNS SRV record to specify available services. Example:
mysqlx::Session sess(
SessionOption::HOST, “example.com”,
SessionOption::DNS_SRV, true,
SessionOption::USER, “user”,
SessionOption::PWD, “password”);

Similarly, for X DevAPI for C, the mysqlx_session_option_set() function permits an OPT_DNS_SRV() option in the argument list. Example: mysqlx_session_option_set(opt,
OPT_HOST(“example.com”),
OPT_DNS_SRV(true)
OPT_USER(“user”),
OPT_PWD(“password”),
PARAM_END));

+ For applications that use the legacy JDBC API (that is, not made using X DevAPI or X DevAPI for C), connection maps permit an OPT_DNS_SRV element. A map should specify the host for SRV lookup as a full lookup name and without a port. Example:
sql::ConnectOptionsMap opts;
opts[“hostName”] = “_mysql._tcp.host1.example.com”;
opts[“OPT_DNS_SRV”] = true;
opts[“userName”] = “user”;
opts[“password”] = “password”;
driver->connect(opts);

In legacy applications, DNS SRV resolution cannot be enabled in URI connect strings because parameters are not supported in such strings.

Bugs Fixed

* Connector/C++ failed to compile using Clang on Linux. (Bug #30450484)

* Connector/C++ set the transaction isolation level to REPEATABLE READ at connect time, regardless of the current server setting. (Bug #22038313, Bug #78852, Bug #30294415)

On Behalf of MySQL Release Engineering Team,
Surabhi Bhat