C# 不允许将nvarchar数据类型隐式转换为varbinary(max)。使用CONVERT函数执行此查询

C# 不允许将nvarchar数据类型隐式转换为varbinary(max)。使用CONVERT函数执行此查询,c#,entity-framework,sql-update,entity-framework-plus,C#,Entity Framework,Sql Update,Entity Framework Plus,以下代码: byte[] image1 = ConvertTo.Bytes(Request.Files[0]); byte[] image2 = null; ctx .Users .Where(x => x.Id == 1) .Update(x => new User() { ImageByte1 = image1, ImageByte2 = image2 }); 表定义: ImageByte1 varbinary(最大值)是否允许空值?真的 ImageByte2

以下代码:

byte[] image1 = ConvertTo.Bytes(Request.Files[0]);
byte[] image2 = null;

ctx
.Users
.Where(x => x.Id == 1)
.Update(x => new User()
{
    ImageByte1 = image1,
    ImageByte2 = image2
});
表定义:

ImageByte1 varbinary(最大值)是否允许空值?真的

ImageByte2 varbinary(最大值)是否允许空值?真的

我在这里用这个:

只有当我将null设置为
ImageByte2
时才会出现问题。以下错误:

将nvarchar数据类型隐式转换为varbinary(max) 这是不允许的。使用CONVERT函数执行此查询

现在它的I定义
ImageByte1
ImageByte2
null
,它会正常更新或
ImageByte1
ImageByte2
而不是null也会更新


有什么解决方案吗?

问题已经用最新版本解决了


Nuget:

哦,你考虑过空字节数组而不是空字节数组吗?@ErikE,是的,我希望是空字节数组null@ErikE,后期编辑显示您的表定义。@JanMuncinsky,后期编辑