MySQL Connector/NET 7.0.5 m4 Development Release has been released

Dear MySQL users,

MySQL Connector/Net 7.0.5 is the second development release that expands cross-platform support to Linux and OS X 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 OS X. We are very excited about this change and really look forward to your feedback on it!

MySQL Connector/Net 7.0.5 is also the fourth 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 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.

Please note that 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 http://dev.mysql.com/doc/refman/5.7/en/document-store.html.

To download MySQL Connector/Net 7.0.5 M4, see the “Development Releases” tab at http://dev.mysql.com/downloads/connector/net/

Changes in MySQL Connector/Net 7.0.5 (2016-09-06, Milestone 4)

Functionality Added or Changed

  • Added support for snapshot change-tracking by recording the original values of an entity when it is retrieved from the database, and support to access the tracked state of entities through DbContext.Entry and DbContext.ChangeTracker.
  • Added concurrency tokens and shadow properties to the set of conventions used to build an Entity Framework Core model based on the shape of entity classes.
  • The .NET Core version of the driver now supports connections to MySQL servers configured to use SSL (TSL for 5.7) through the MySqlConnection class or a DbContext with Entity Framework 6.x or Entity Framework Core.
  • Entity Framework Core support for eager loading can be used to load related data from MySQL as part of the initial query.
  • Added X DevAPI support for following connections options:
    • ssl-enable: enables the use of SSL as required. mysqlx://user:password@192.2.0.1/?ssl-enable
    • ssl-ca: path to a local file that contains a list of trusted TLS/SSL CAs as PFX file. This option uses an implicit ssl-enable. mysqlx://user:password@server.example.com/?ssl-ca=(c:\cas.pfx)
    • ssl-ca-pwd: specifies the CA certificate password. mysqlx://user:password@server.example.com/?ssl-ca=(c:\cas.pfx)&ssl-ca-pwd=password

Nuget packages are available at:

MySql.Data package. Compatible with .NET 4.5.1 and Core framework 1.0

MySql.Data.EntityFrameworkCore. Compatible with .NET 4.5.1 and Core framework 1.0

MySql.Web. Compatible with .NET 4.5.1

MySql.Data.Entity Compatible with .NET 4.5.1

We love to hear your thoughts or any comments you have about our product. Please send us your feedback at our forums, fill a bug at our community site, or leave us any comment at the social media channels.

Enjoy and thanks for the support!

On behalf of the MySQL Connector/Net team

 

HowTo: Starting with MySQL EF Core provider and Connector/Net 7.0.4

This article shows the essential parts of the configuration for a quick console application using the .NET Core command-line (CLI) tool. The application will show how to create an EF Core model and some basic operations that can easily be done in Windows, Linux or OSx.

1. Requirements

Install the sdk, framework and tools:

Windows:
Install
– .NET Core SDK for Windows direct link here
– Visual Studio 2015 Update 3* here’s the publication page with more information about the update.
– .NET Core 1.0 tooling for Visual Studio direct link here

Linux:
An official detailed guide can be followed here.

OSx:
Follow the instructions and download the official installer here

2. Create the console application

This tutorial shows instructions for developing the application in Windows, but the same application can be done just changing the commands to the equivalent in the corresponding platform.

1. Create a folder where the new project will be saved.

On a command prompt type:
> mkdir efcore

2. Create the project
> cd efcore
> dotnet new

3. Create an appsettings.json file to hold your connection string information. Example:

Note: Adjust your server settings accordingly to your MySQL server configuration and user.

Notice the sslmode key in the connection string. This tells the server to use a plain connection instead of a secured one. If you like to use ssl mode then change this value to Preferred.

4. Modify the project.json to add the EntityFrameworkCore dependencies, add the MySQL references and specify that the appsettings.json file must be copied to the output (buildOptions section) so it becomes available to the application when building it.

The result should look like the following:

5. After project.json modifications a restore of the packages in the application is mandatory. This command will download all the dependencies needed. In the console window type the following:

> dotnet restore

6. Create a database context for Entity Framework
Inside a text editor, or the IDE you prefer to use, create a EmployeesContext.cs file.
Here is an example of a context with some entities.

7. Replace the contents of the Program.cs file with the following code:

8. Build the application with the following command:

> dotnet build

9. Run the application

> dotnet run

The output from this console application is:

Employee was saved in the database with id: 1

Conclusion

Entity Framework is a well known technology for data access in .NET applications. With this new Core version, developers can create applications for Windows, Linux and OSX without changing the application code. The MySQL provider and EF core is a great combination for applications that target the new .NET Core version.

We love to hear your thoughts or any comments you have about our product. Please send us your feedback at our forums, fill a bug at our community site, or leave us any comment at the social media channels in Twitter or Facebook.

Enjoy and thanks for the support!

On behalf of the MySQL Connector/Net team

MySQL Connector/NET 7.0.4 m3 has been released

Dear MySQL users,

MySQL Connector/Net 7.0.4 is the first development release that expands cross-platform support to Linux and OS X 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 OS X. We are very excited about this change and really look forward to your feedback on it!

MySQL Connector/Net 7.0.4 is also the third 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 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.

Please note that 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 http://dev.mysql.com/doc/refman/5.7/en/document-store.html.

To download MySQL Connector/Net 7.0.4 M3, see the “Development Releases” tab at http://dev.mysql.com/downloads/connector/net/

Also you can find the new nuget packages for the .net core framework at the nuget gallery or using the following direct links:

MySql.Data package for core framework

MySql.Data.EntityFrameworkcore for core framework

Packages for full .net framework

MySql.Data package

MySql.Data.Entity package

MySql.Web package

MySql.Fabric package

Functionality Added or Changed in 7.0.4 M3 development release

  • Added X DevAPI support for URI connection strings in the following formats:
    mysqlx://[<user>[:<password>]@]<host>[:<port>]
    mysqlx://[<user>[:<password>]@]<host>[:<port>]/<database>
    mysqlx://[<user>[:<password>]@]<host>[:<port>]/[<database>]?<option>=<value>[&<option>=<value>]
    mysqlx+ssh://[<user>[:<password>]@]<host>[:<port>]
  • Added X DevAPI support for flexible parameter lists that do not require string parsing.
  • Views are no longer implemented using a separate View class in the X DevAPI. Instead, the IsView property has been added to the Table class and views are implemented as tables.
  • Added in MySql.Data support for .NET Core 1.0, which runs on Windows, OS X, and Linux.
  • Added in MySQL.Data.EntityFrameworkCore support for Entity Framework (EF) Core (includes support for .NET Framework 4.5.1).

Bugs Fixed

  • Passing no document or a DbDoc object that contained an empty array to the Add() method of a collection would throw an exception. Now, passing in either an empty document or array of documents returns a Results object in which RecordsAffected is zero. (Bug #23542066)
  • Passing a DbDoc object that contained an array to the Add() method of a collection would throw an exception. (Bug #23542031)

We love to hear your thoughts or any comments you have about our product. Please send us your feedback at our forums, fill a bug at our community site, or leave us any comment at the social media channels.

Enjoy and thanks for the support!

On behalf of the MySQL Connector/Net team

MySQL Connector/NET 6.8.8, and 6.9.9 have been released

Dear MySQL users,

MySQL Connector/Net 6.8.8 and 6.9.9 are maintenance releases for the 6.8 and 6.9 series of the .NET driver for MySQL. They can be used for production environments.

It is appropriate for use with MySQL server versions 5.5-5.7.

These are now available in source and binary form from our downloads and mirror sites. (note that not all mirror sites may be up to date at this point-if you can’t find this version on some mirror, please try again later or choose another download site.)

Functionality Added or Changed

  • Added TLS support for TLSv1.1 and TLSv1.2 when connecting to MySQL Server 5.7.

Bugs Fixed

  • Improvements were made to how the connector handles aborted connections. (Bug #23346197, Bug #80997).
  • With Entity Framework 6, building a table with a primary key would not enclose the key name in quotes, which caused a syntax error. (Bug #22696180, Bug #22696207, Bug #76292).
  • The connector was not disposing the transaction returned by DBContext.Database.BeginTransaction() when exiting a using code block. (Bug #22514355, Bug #22514363).
  • The connector did not attempt to enumerate stored procedures via mysql.proc(). Instead it looked up stored procedures in INFORMATION_SCHEMA.ROUTINES. This could have led to performance degradation in certain scenarios. (Bug #20960373, Bug #23528155, Bug #74116)

For documentation please check at the official site.

Nuget packages are available at:

6.9.9 Packages

MySql.Data 6.9.9

MySql.Data.Entity 6.9.9

MySql.Fabric 6.9.9

MySql.Web 6.9.9

6.8.8 Packages

MySql.Data 6.8.8

MySql.Data.Entity 6.8.8

MySql.Web 6.8.8

We love to hear your thoughts or any comments you have about our product. Please send us your feedback at our forums, fill a bug at our community site, or leave us any comment at the social media channels.

Enjoy and thanks for the support!

On behalf of the MySQL Connector/Net team

MySQL Connector/NET 7.0.3 m2 development has been released

MySQL Connector/Net 7.0.3 is the second development release of MySQL Connector/Net  7.0 series.

MySQL Connector/Net 7.0 adds support for the new X DevAPI which enables 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 this User’s Guide. For more information about how the X DevAPI is implemented in Connector/Net, please check the official product documentation.

Please note that 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 this chapter at the reference manual.

Changes in MySQL Connector/Net 7.0.3 (2016-06-20, Milestone 2)

Functionality Added or Changed:

  • Fixed binary collations as strings instead of bytes.
  • Added TLS support for TLSv1.1 and TLSv1.2 when connecting to MySQL Server 5.7.

Bugs Fixed:

  • Added results to the Commit() and Rollback() Session X DevAPI methods, in order to read Warnings. This feature has limitations that will be addressed in a future release.
  • Replaced the use of “@” for “$” in JSON path expressions for X DevAPI usage. This feature has limitations that will be addressed in a future release.
  • Added X DevAPI support for TLSv1.0. This feature has limitations that will be addressed in a future release.

Nuget packages are available at:

https://www.nuget.org/packages/MySql.Data/7.0.3-DMR

https://www.nuget.org/packages/MySql.Data.Entity/7.0.3-DMR

https://www.nuget.org/packages/MySql.Fabric/7.0.3-DMR

https://www.nuget.org/packages/MySql.Web/7.0.3-DMR

We love to hear your thoughts or any comments you have about our product. Please send us your feedback at our forums, fill a bug at our community site, or leave us any comment at the social media channels.

Enjoy and thanks for the support!

On behalf of the MySQL Release Team

MySQL Connector/Net 7.0.2 has been released

Dear MySQL users,

MySQL Connector/Net 7.0.2 M1 is the first development release that adds 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 this User Guide. For more information about how the X DevAPI is implemented in Connector/Net, please check the official product documentation.

Also note that 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 this chapter at the reference manual.

Changes in MySQL Connector/Net 7.0.2 (2016-04-11, Milestone 1)

Functionality Added

  • Added support for the new X DevAPI

Nuget packages are available at:

https://www.nuget.org/packages/MySql.Data/7.0.2-DMR

https://www.nuget.org/packages/MySql.Data.Entity/7.0.2-DMR

https://www.nuget.org/packages/MySql.Fabric/7.0.2-DMR

https://www.nuget.org/packages/MySql.Web/7.0.2-DMR

We love to hear your thoughts or any comments you have about our product. Please send us your feedback at our forums, fill a bug at our community site, or leave us any comment at the social media channels.

Enjoy and thanks for the support!

On behalf of the MySQL Connector/Net Team

 

Connector/Net joins MySQL products on Github

We are very pleased to announce that the MySQL Connector/Net source code has been added to GitHub. All of our versions can be found at MySQL Connector/Net repository, under the umbrella of the MySQL organization. This repository will expose the source code of the latest generally available (GA) releases. Same versions that are available in the official MySQL download site.

There are no changes to the releases cycles or the channels that we use for publishing new versions of Connector/Net. The purpose of publishing on GitHub is providing our users a quicker way to get the source code of all our GA versions. The repository contains all history since 6.7 alpha version.

You can clone the repository or download the source code at the GitHub site or using any Git client of your preference.

At the Git shell you can type:

$ git clone https://github.com/mysql/mysql-connector-net.git

Obviously, in order to execute git commands, you’ll have to install it previously in your computer. You can follow the official getting started guide in case you need some help for that.

We love to hear your thoughts or any comments you have about our product. Please send us your feedback at our forums, filing a bug at our community site, or at the social media channels.

Hope you found this information useful.

Thank you!

On behalf of the MySQL Connector/Net team.

 

 

 

MySQL Connector/NET 6.7.9, 6.8.7, and 6.9.8 have been released

Dear MySQL users,

MySQL Connector/Net 6.7.9, 6.8.7, and 6.9.8 are maintenance releases for the series of the .NET driver for MySQL. They can be used for production environments.

They are appropriate for use with MySQL server versions 5.5-5.7.

  • The GB18030 Chinese character set is now supported, a character set that was added in MySQL 5.7.4.
  • The JSON type is now supported, a type that was added in MySQL 5.7.8.
  • Generated columns (GENERATION_EXPRESSION) are now supported, a feature added in MySQL 5.7.6.

An additional entry added for 6.8.7:

  • A connection string that included Chinese characters for a database or uid property would emit the following exception;
    “MySqlException: Unknown database ‘???'”. To solve this, the handshake process was hanged to use bytes instead of encoded strings.

The documentation is available at:
http://dev.mysql.com/doc/connector-net/en/

Nuget packages are available at:
https://www.nuget.org/packages/MySql.Data/
https://www.nuget.org/packages/MySql.Data.Entity/
https://www.nuget.org/packages/MySql.Fabric/
https://www.nuget.org/packages/MySql.Web/

Enjoy and thanks for the support!

On behalf of the MySQL Connector/NET Team.

 

 

How to use MySQL for your ASP.NET Identity provider with a custom primary key

Image

One of the most important things in any application is having a good and well back up security mechanism that ensures the access to the site or application is well managed and controlled.

With the ASP.NET Identity provider you have a balance between customization and a good separation between the storage of the identity information and the code that implements the security system. This separation allows to have a very good customization in terms of the information that the application will store from each one of the users and roles. (more information and context here)

Here are some important features within the ASP.NET Identity provider

  • A higher level of customization of the data associated with the user account.
    Developers have the facility to add or change the data stored of the user by implementing the IUser interface. All the data will be stored by doing the implementation of the IUserStore interface.
  • Entity Framework 6 support. There are defaults implementations of the IUser and IUserStore interfaces in Entity Framework 6. For the IUser interface there is a class called ApplicationUser and another one called UserStore for the IUserStore interface. This makes it very straightforward for developers to know which data is stored and how it is stored. Finally there is an ApplicationDbContext class for the developers to setup a connection string to indicate the database to be used.
  • Asynchronous support and many virtual methods. A good amount of methods have asynchronous support which many of the applications can benefit from. Here you can see more documentation about it. Also, most of the APIs are virtual; if the developer needs to customize any of the built-in behavior then he would simply override the appropriate method.

In this post we will build an MVC application using ASP.NET Identity provider with an integer primary key, which will require some changes to the default template. The provider is by default using the UUID type so with MySQL we will do the necessary changes to use an integer type instead as the primary key for the users table.

Requirements:

– Visual Studio 2013 update 4
– A running server with MySQL 5.6 (can be downloaded here).
– Connector/Net 6.9.6 (download it here)

Create the MVC Application

Open Visual Studio 2013 and click on File Menu and select New Project. Make sure you are using the .Net 4.5 Framework version.

New Project - Microsoft Visual Studio

Select the Web Category and then select the ASP.NET Web Application to start with the template that has the ASP.NET Identity provider set up already. Notice that the type of Authentication used is by default Individual User Accounts, which is the one using ASP.NET Identity provider.

Select a template - ASPIdentityWebApplication

Customizing the application 

Once the application is created there are two files related to the Identity provider back end: IdentityModel and IdentityConfig. Here’s an image that highlights these two files.

SolutionExplorer - App parts

Step One: Customization of the ApplicationUser class

We have mentioned that the ApplicationUser class is the one that implements the IUser interface, hence we would have to use the implementation with the generic type for the primary key in order to customize it. Documentation of the API in this class can be checked here

Open the IdentityModels.cs file, and change the definition of the ApplicationUser class to be like the following:

 

The signature of this class has the following type parameters:

int: The type of the key, for this case int.
UserLoginIntIntPk: The type of the login.
UserRoleIntPk: The type of the role.
UserClaimIntPk:n The type of the claim.

Due the usage of this constructor it is necessary to add the following new classes:

 

After adding these classes, comes the personalization of the IUserStore interface.

Add the following code to the IdentityModels file:

 

Lastly the IdentityDbContext class customization:

 

Notice the integer type used on each of the classes definition.

Step two: Customize the IdentityConfig.cs file

Change the following “old code” to the “new code”:

Old Code:

 

New Code:

 

Old Code:

 

New Code:

 

Old Code:

 

New Code:

 

Old Code:

 

New Code:

 

Third Step: Open the Startup.Auth.cs from App_Start folder and change “old code” to the “new code”:

Old Code:

 

New Code:

 

Fourth Step: Changes in the AccountController file

Old Code:

 

New Code:

 

In the internal class ChallengeResult change the UserId type to the integer type:

 

New Code:

 

Fifth Step: Web.config file changes.

The connection string should look like this in the web configuration file:

 

Change the value to the credentials you will be using and make sure you also include the port in the connection string, if the port is not 3306, which is the default value.

The EntityFramework section also has to include the MySQL provider:

 

Running the Application

Once all the changes are done, we can run the application and create a user.

RegisterUser

Login page:

LoginUser

The structure of the database created by the provider is shown in the image:

ShowTables;

The data of the user in the user’s table:

SelectUsers

That’s all

Conclusion:

The ASP.NET Identity provider is a very good option to manage authentication data with a good level of customization. In this example we changed the default values used to the ones that let us define a different data type for the primary key.

Quick links

Hope you find this information useful.