Connector/J moves to Git

I’m pleased to announce that Connector/J has a new home.

Just as several other MySQL products, Connector/J source code management moved to Git and, pretty much as expected, to GitHub. Our reasoning is nothing else than listening to our users demands and trying to follow best trends and practices. There was nothing significantly wrong with Bazaar and Launchpad, as they served us well for the last seven years. It was just time to move on.

Rest assured, all will work as before, no complications no hassles. Our public GitHub repository will expose Connector/J source code as it is in the latest generally available (GA) release, as it has been for the last years.

From now on you will find Connector/J source code in the well known Git repository hosting service, GitHub, at mysql-connector-j under the umbrella of MySQL organization. Other MySQL products will follow in time. This repository contains all history since Connector/J early days so nothing was lost. Those who are used to our old launchpad repository will only have to change tools.


GitHub allows you to explore source code, project history, get to know about contributions and a lot more. But you probably already know all of this anyway.

So, to get the Connector/J source code you can just execute the following command in your preferred shell or command prompt:

You can also fetch the code through SSH protocol, using Subversion or simply download it as a zip file. Obviously, in order for you to execute git commands, you’ll have to have it installed in your computer. Just follow the official getting started guide if you don’t have it yet.

Building MySQL Connector/J 5.1 from source

Some time ago I have blogged about building Connector/J from source code. Nothing changes in this post, except for the replacement of Bazaar and Launchpad by Git and GitHub respectively and the  bzr  command that is replaced by the  git  command mentioned above.

We love to hear from you

As always, don’t forget to use our official channels to report us your wishes, findings or just ask for help when you need it. We can be found at MySQL Bugs database or MySQL Connector/JDBC and Java forum. Thank you!

Welcome to Connector/J on Git!
Farewell Bazaar. Farewell Launchpad. Thank you for the 7 years of good services.

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


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.


– 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.


Login page:


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


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


That’s all


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.