MySQL Connector/Net 8.0.8-dmr has been released

MySQL Connector/Net 8.0.8 is the fifth development release that expands cross-platform
support to Linux and macOS when using Microsoft’s .NET Core framework. Now, .NET
developers can use the X DevAPI with .NET Core and Entity Framework Core (EF Core)
1.0 to create server applications that run on Windows, Linux and macOS. We are very
excited about this change and really look forward to your feedback on it!

MySQL Connector/Net 8.0.8 is also the seventh development release of MySQL
Connector/Net to add support for the new X DevAPI. 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
For more information about how the X DevAPI is implemented in Connector/Net, see


The X DevAPI requires at least MySQL Server version 5.7.12 or higher with the X
Plugin enabled. For general documentation about how to get started using MySQL
as a document store, see

To download MySQL Connector/Net 8.0.8-dmr, see the “Development Releases” tab at


Changes in MySQL Connector/Net 8.0.8 (2017-07-10, Development Milestone)

   MySQL Connectors and other MySQL client tools and
   applications now synchronize the first digit of their version
   number with the (highest) MySQL server version they support.
   For example, MySQL Connector/Net 8.0.12 would be designed to
   support all features of MySQL server version 8 (or lower).
   This change makes it easy and intuitive to decide which
   client version to use for which server version.

   MySQL Connector/Net 8.0.8 is the first release to use the new
   numbering. It is the successor to MySQL Connector/Net 7.0.7.

     * Functionality Added or Changed

     * Bugs Fixed

   Functionality Added or Changed

     * X DevAPI: The format of document ID values generated when
       adding documents to a collection has changed. It is still
       a string of 32 hexadecimal digits based on UUID, but the
       order of digits was changed to match the requirement of a
       stable ID prefix.

     * All connections created using MySQL Connector/Net now are
       secure by default. Also, the Ssl-Enable connection option
       has been replaced by Ssl-Mode. Permitted Ssl-Mode values
       are None, Required (the default), VerifyCA, and

       With this change, a non-SSL enabled server now requires
       the Ssl-Mode option be set to None explicitly in the
       connection string or the connection will fail.

     * X DevAPI: It is no longer permitted to pass an empty
       search condition, such as the NULL value or an empty
       string, to the Collection.Modify and Collection.Remove
     * X DevAPI: The NodeSession class has been renamed to
       Session and the MySQLX.GetNodeSession method has been
       renamed to MySQLX.GetSession. Also, the XSession class
       has been removed.

     * X DevAPI: When creating a new connection, multiple hosts
       now can be specified as part of the connection string,
       which will try each host until a successful connection is
       established or all elements from the host list have been
       tried. The following connection-string formats are

	    var mySession = MySQLX.GetSession(
	      "mysqlx://dbuser:password@[" +
	      "localhost:33060," +
	      "," +
	      "[2001:db8:85a3:8d3:1319:8a2e:370:7348]:33060" +

	    var mySession = MySQLX.GetSession(
	      "user=dbuser;" +
	      "password=dbpassword;" +
	      "server=" +
	      "," +
	      "," +
	      "localhost;" +

   Bugs Fixed

     * EF Core: The Database First feature did not support the
       following data types: BINARY, VARBINARY, MEDIUMBLOB,
       LONGBLOB, SET, DATE, TIME, and YEAR. (Bug #25493209)

     * EF Core: Database First support produced an error when
       the existing MySQL database included one or more views.
       (Bug #25493086)

     * EF Core: Using
       te to initialize a new class instance that specified the
       name of an existing MySQL table produced incorrect
       mappings of table and column names.
       (Bug #25394223, Bug #84423)


Packages are available at:

Enjoy and thanks for the support!

On Behalf of MySQL/Oracle Release Engineering Team
Prashant Team

Getting started with ASP.NET Core and MySQL Connector/NET

This tutorial shows how to read information from MySQL Sakila database in an ASP.NET Core application using Connector/NET Core to explore the possibility to run this application on any .NET Core supported environment as Windows, Linux, and Mac.


Windows and Visual Studio 2015

The first step is to create an ASP.NET Core Web Application (.NET Core) type project and name it MvcSakilaCore

Note: the project name should not contain spaces



Select Web Application template and No Authentication:


The new project will be created:


Press F5 to run the application:


Stop the running application to add some code.

Creating the data model

Create a new folder named “Models” where it will store the database access:


Installing MySQL Connector/NET Core package

In order to use MySQL Connector/NET it’s required to add its nuget package.

In Solution Explorer, right-click MvcSakilaCore project > Manage NuGet Packages…
In the NuGet dialog, Browse “MySql.Data” package using version 6.10.0 or above:


Adding the connection string

Add your connection string in the appsettings.json file:


Adding data model classes

For this example a Film class will be used. It contains the database fields as properties we want to show in our application.

Add a new class named “Film” inside Models folder:

using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace MvcSakilaCore.Models
  public class Film
    private SakilaContext context;

    public int FilmId { get; set; }

    public string Title { get; set; }

    public string Description { get; set; }

    public int ReleaseYear { get; set; }

    public int Length { get; set; }

    public string Rating { get; set; }

Create a new SakilaContext class that will contains the connections and Sakila database entities:

using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;

namespace MvcSakilaCore.Models
  public class SakilaContext
    public string ConnectionString { get; set; }

    public SakilaContext(string connectionString)
      this.ConnectionString = connectionString;

    private MySqlConnection GetConnection()
      return new MySqlConnection(ConnectionString);

    public List<Film> GetAllFilms()
      List<Film> list = new List<Film>();

      using (MySqlConnection conn = GetConnection())
        MySqlCommand cmd = new MySqlCommand("SELECT * FROM film", conn);
        using (MySqlDataReader reader = cmd.ExecuteReader())
          while (reader.Read())
            list.Add(new Film()
              FilmId = reader.GetInt32("film_id"),
              Title = reader.GetString("title"),
              Description = reader.GetString("description"),
              ReleaseYear = reader.GetInt32("release_year"),
              Length = reader.GetInt32("length"),
              Rating = reader.GetString("rating")

      return list;

In order to be able to use our SakilaContext it’s required to register the instance as a service in our application. To do this add the code line in the Startup.cs file:


Adding Film Controller

In Solution Explorer, right-click Controllers > Add > New Item… > MVC Controller Class
Name the controller FilmsController:



Change the FilmsController code to this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using MvcSakilaCore.Models;

// For more information on enabling MVC for empty projects, visit

namespace MvcSakilaCore.Controllers
  public class FilmsController : Controller
    // GET: /<controller>/
    public IActionResult Index()
      SakilaContext context = HttpContext.RequestServices.GetService(typeof(MvcSakilaCore.Models.SakilaContext)) as SakilaContext;

      return View(context.GetAllFilms());

Creating the Films View

Start creating the Films folder under Views:

In Solution Explorer, right click Views > Films > Add > New Item… > ASP.NET > MVC View Page


Add the following code into the new Index.cshtml view file:

@model IEnumerable<MvcSakilaCore.Models.Film>
  ViewBag.Title = "Films";
<table class="table">
    <th>Film ID</th>
    <th>Release Year</th>
  @foreach (var item in Model)
        @Html.DisplayFor(modelItem => item.FilmId)
        @Html.DisplayFor(modelItem => item.Title)
        @Html.DisplayFor(modelItem => item.Description)
        @Html.DisplayFor(modelItem => item.ReleaseYear)
        @Html.DisplayFor(modelItem => item.Length)
        @Html.DisplayFor(modelItem => item.Rating)

Before run the application, add the Films path to the running url.

In Solution Explorer, right click MvcSakilaCore > Properties > Debug > Launch URL > Films:


Run the application (press F5) and the Films list should be displayed: