Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1447

EntityFramework string column types. (no replies)

$
0
0
I just re-built connector for my own purpose, with this fix ( http://forums.mysql.com/read.php?38,519005,525880#msg-525880 ). While looking further through the code, i ran into this :

if (isFixedLength)
{
typeName = isMaxLength || maxLength > CHAR_MAXLEN ? "varchar" : "char";
maxLength = isMaxLength ? VARCHAR_MAXLEN : maxLength;
}
else
{
if (maxLength < CHAR_MAXLEN) typeName = "tinytext";
if (maxLength < VARCHAR_MAXLEN) typeName = "text";
if (maxLength < MEDIUMTEXT_MAXLEN) typeName = "mediumtext";
else typeName = "longtext";
}

Correct me if I'm wrong, but it seems that this code will always generate MEDIUMTEXT columns for variable length string with length < MEDIUMTEXT_MAXLEN.

You might want to change the "else" block for something like this :

if (maxLength < CHAR_MAXLEN) typeName = "tinytext";
else if (maxLength < VARCHAR_MAXLEN) typeName = "text";
else if (maxLength < MEDIUMTEXT_MAXLEN) typeName = "mediumtext";
else typeName = "longtext";


(Besides this, as I'm not aware of a way to define a fixed length string while using EF Code First, it will generate a mediumtext whenever you want a string... that is not a novel.)

Viewing all articles
Browse latest Browse all 1447

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>