且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MVC模型如何使byte []可为空?

更新时间:2023-10-15 16:06:16

[Column(TypeName = "image")]
public byte[] Avatar { get; set; }

我认为您需要告诉EF您正在以这种方式使用它.尝试使用上述图像批注.

I think you need to tell EF that you are using it in this fashion. Try using the image annotation as above.

这将确保将您的字段创建为图像类型;为这种情况设计的.

This will make sure your field is created as the image type; designed for this type of scenario.

编辑:请查看注释以获取最终的答案.

Please see the comments for the answer that eventually worked.