Marjan Nikolovski
Marjan Nikolovski

Reputation: 848

MySQL connector v.6.3.6 problem with GUID type in .NET

I am having a table with identifier GUID in mysql (binary 16). To execute CRUD operations i use EF driver that comes with the installation of mysql connector v.6.3.6. When trying to insert a new object through EF it fails with error {"Data too long for column 'MyIdentifierColumnId' at row 1"}

MyIdentifierColumnId is binary 16 and translated as GUID in .NET. So the length should not be an issue.

Any hints ?

Upvotes: 2

Views: 2974

Answers (2)

Andrius V.
Andrius V.

Reputation: 154

Your answer was very helpful, thanks. But I had problems by adding this "Old Guids=true" I was not shore how and where to add it, my connection was failing. So it might be helpful for others to have this piece of code:

 string connectionString;
 connectionString = "SERVER=" + server + ";" + "DATABASE=" +
 database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";Old Guids=true;";

 connection = new MySqlConnection(connectionString);

Upvotes: 3

Marjan Nikolovski
Marjan Nikolovski

Reputation: 848

According to the http://dev.mysql.com/doc/refman/5.1/en/connector-net-connection-options.html Columns defined as binary(16) or char(36) are treated as old guids. In the new version UUID are introduced and if we want to use Old Guids=true in the connection string.

Upvotes: 4

Related Questions