简体   繁体   English

Base64字符串的实体框架列类型

[英]Entity Framework Column Type for Base64 String

I am using code first Entity Framework and four of my columns are a base64 representation of an image and are of type string. 我先使用代码Entity Framework,而我的四列是图像的base64表示形式,并且是字符串类型。 Initially, I was allowing EF to store these as the default nvarchar(max). 最初,我允许EF将它们存储为默认的nvarchar(max)。 I learned today that nvarchar(max) is twice the size of what the data actually is, when dealing with images this difference is tremendous. 我今天了解到,nvarchar(max)的大小是数据实际大小的两倍,在处理图像时,这种差异是巨大的。

I've tried to use varchar, but it appears the max length on that is 8000 which is too small for a base64 image. 我尝试使用varchar,但它的最大长度似乎是8000,对于base64映像来说太小了。 I've also tried text, but that does not appear to be a valid type. 我也尝试过文字,但这似乎不是有效的类型。

Any suggestions for what may be a good type that will support the length of the data while maintaining a reasonable size? 对于什么可能会在保持合理大小的同时支持数据长度的好类型的任何建议?

您可以尝试varchar(max) text

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM