Bug #54915 Wrong handling of fixed length string columns by Entity Framework provider
Submitted: 30 Jun 2010 14:05 Modified: 29 Sep 2011 20:59
Reporter: Thomas Zehetner Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:Connector/Net 6.3.2 beta OS:Windows
Assigned to: Fernando Gonzalez.Sanchez CPU Architecture:Any
Tags: entity framework

[30 Jun 2010 14:05] Thomas Zehetner
Description:
When adding a string colum to an entity in Visual Studio the facet "Fixed length" can be set to true or false. "Fixed length" determines, if the column is of type char (Fixed length = true) or varchar (Fixed length = false).

The "Max length" facet determines the maximum length of the text column. Currently it's not allowed to add a column with "Fixed length" = false and "Max length" > 65535, because varchar does not support more than 65535 characters.

In my opinion variable length columns with a maximum length greater than 65535 should be allowed. Entity Framework should use the mediumtext and longtext types for these columns.

At the moment you have to make the column long enough and set "Fixed length" to true, to get a mediumtext or longtext column. This is not correct because mediumtext and longtext does not have a fix length. Moreover that leads to problems, when generating database creation scripts for other databases because providers for other databases will correctly create char columns.

How to repeat:
1) Create an entity data model item in Visual Studio.
2) Add an entity to the model.
3) Add string colums with different settings for Max length and Fixed length to the entity
4) Generate the database model from model and compare the generated create table statements.

Suggested fix:
Change the entity framework provider so that it allows string columns with "Fixed length" = false and "Max length" > 65535.

Max length <= 65535 -> use varchar
Max length between 65536 and 16777215 -> use mediumtext
Max length > 16777215 -> use longtext
[30 Jun 2010 15:06] Thomas Zehetner
Added connector version.
[29 Sep 2011 20:59] Fernando Gonzalez.Sanchez
Thank you for your bug report. This issue has already been fixed in the latest released version of that product, which you can download at

  http://www.mysql.com/downloads/

This was fixed in 6.3.8 & 6.4.4.
[29 Feb 2012 21:27] John Russell
Added to changelog for 6.3.8, 6.4.4: 

When adding a MEDIUMTEXT or LONGTEXT column Visual Studio, the facet
Fixed length had to be set to false, even though these types allow
arbitrary lengths.