Skip to content

varchar(max) means 2GB in SqlServer, not 8092, EF CodeFirst Gets it right

Updated: at 05:05 PM

I wasted about 30 minutes wrestling with a EF CodeFirst type issue today.  I was creating an attribute for what I wanted to be a large text field and not have it limited to 8092 bytes which what I incorrectly thought required it to be something like varbinary, text or image types.  My CodeFirst code looks like this:


   1: [Column(TypeName = "Text")]   

   2: public string MimeMessageFull { get; set; }


What got created in my SqlServer database is the following:

   1: [MimeMessageFull] varchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

I kept changing things trying to make it text, image or varbinary with no success.  Finally, I ran into this url:

which says clearly varchar(max) is the new image type.


So, there you have it.  ntext,text and image are out!