Bug #64288 .NET Entity Framework SQL Generator never uses 'VARCHAR'
Submitted: 10 Feb 2012 2:54 Modified: 12 Sep 2012 19:06
Reporter: Mauricio Morales Email Updates:
Status: Duplicate Impact on me:
Category:Connector / NET Severity:S2 (Serious)
Version:6.4.4 OS:Microsoft Windows
Assigned to: Assigned Account CPU Architecture:Any
Tags: entity framework, varchar

[10 Feb 2012 2:54] Mauricio Morales
In Bug #54915 was requested to use "mediumtext" and "longtext" data types because VARCHAR wasn't the perfect fit for all scenarios. Now we've gone the other way. No matter what "Fixed Length" and "Max Length" sets, it'll always use "MEDIUMTEXT"... even if my column has a Max Length of 3 chars!!

How to repeat:
1. Create an Empty Entity Framework Model and select the SSDLtoMySQL.tt DDL generation template
2. Create an entity (whatever name you want)
3. Create a scalar property (whatever name you want)
4. Set Fixed Length for that Scalar property to False
5. Set Max Length for that Scalar property to 50
6. Right click on the background of the Model and hit "Generate Database from Model..."

I would expect it to generate a VARCHAR(50) column for that Scalar property, but it generates a MEDIUMTEXT (clearly an overkill!!)

Suggested fix:
It should use VARCHAR when Max Length is <65535. It's good to use Medium and Long text data types, but not for the lower end of the Max Length spectrum.
[16 Feb 2012 22:20] Gabriela Martinez Sanchez
A patch for this bug has been commited and it's waiting for review.
[4 May 2012 19:21] Gabriela Martinez Sanchez
This fix is related to the bug 63920.
[12 Sep 2012 19:06] Fernando Gonzalez.Sanchez
Errata: this is duplicated of http://bugs.mysql.com/bug.php?id=65289