为Base64编码字符串实体框架柱类型 [英] Entity Framework Column Type for Base64 String

查看:160
本文介绍了为Base64编码字符串实体框架柱类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用code第一实体框架和我的专栏中有四个图像的一个base64再presentation并且是字符串类型。起初,我被允许EF将这些存储为默认为nvarchar(最大)。我今天了解到,为nvarchar(max)是什么样的数据实际上是与图像处理时,这种差异是巨大规模的两倍。

I am using code first Entity Framework and four of my columns are a base64 representation of an image and are of type string. Initially, I was allowing EF to store these as the default 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.

我试着使用VARCHAR,但也就是8000这是一个base64图像太小,它出现的最大长度。我也试过文字,但是,这并不似乎是一个有效的类型。

I've tried to use varchar, but it appears the max length on that is 8000 which is too small for a base64 image. 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(最大)

这篇关于为Base64编码字符串实体框架柱类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆