Bug #81025 Guid insert generate exception
Submitted: 9 Apr 2016 22:15 Modified: 12 Apr 2016 7:06
Reporter: ZOKIAD ZOKIAD Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / NET Severity:S4 (Feature request)
Version:6.9.8 OS:Windows
Assigned to: CPU Architecture:Any

[9 Apr 2016 22:15] ZOKIAD ZOKIAD
Description:
When generate a EDMX from a field of type binary(16), edmx generate a type GUID => OK

When try to add a row with GUID, we have an exception:

Data too long for column 'uuid' at row 1

How to repeat:
1/ Create DB

CREATE DATABASE  IF NOT EXISTS `Test` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `Test`;

DROP TABLE IF EXISTS `Test`;
CREATE TABLE `Test` (
  `uuid` binary(16) NOT NULL,
  PRIMARY KEY (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

2/ execute test program in attachment:

            Guid myGuid = Guid.NewGuid();
            Console.WriteLine(myGuid);

            using (TestEntities db = new TestEntities())
            {
                Test newTest = new Test()
                {
                    uuid = myGuid
                };
                db.Tests.Add(newTest);
                db.SaveChanges();
            }

            using (TestEntities db = new TestEntities())
            {
                foreach (Test tst in db.Tests)
                    Console.WriteLine(tst.uuid);
            }

Suggested fix:
wrong sql query generated:
INSERT INTO `Test`(
`uuid`) VALUES (
'f52f946a-14ad-4c85-ba6d-e442a6c894c5')

should be

INSERT INTO `Test`(
`uuid`) VALUES (
0xf52f946a14ad4c85ba6d-e442a6c894c5)
[10 Apr 2016 14:53] ZOKIAD ZOKIAD
Workaround: use OldGuids=true in connection string.
But edmx must don't generate schema with guid type if no OldGuids is not defined
[11 Apr 2016 6:46] Chiranjeevi Battula
Hello ZOKIAD ZOKIAD,

Thank you for the bug report.
As per user manual it is working properly and this option was introduced in Connector/Net 6.1.1.
here is clearly described in the user manual 
https://dev.mysql.com/doc/connector-net/en/connector-net-connection-options.html

Thanks,
Chiranjeevi.
[11 Apr 2016 10:41] ZOKIAD ZOKIAD
I think when generate edmx. The filed binary(16) should not use type guid if OldGuids is not true in connection string. In edmx, this fields should be generate with type binary.

I change the severity to Non-critical.
[12 Apr 2016 7:06] Chiranjeevi Battula
Hello ZOKIAD ZOKIAD,

Thank you for your feedback.
Verified based on internal discussion with dev's and take it as a feature request.

Thanks,
Chiranjeevi.