The implicit conversion of the nvarchar data type into varbinary (max) is not allowed. Use the CONVERT function to perform this query

c# entity-framework entity-framework-plus sql-update

Question

Follow code:

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
});

Table definition:

ImageByte1 varbinary(MAX) Allow nulls? true

ImageByte2 varbinary(MAX) Allow nulls? true

I use this one here: http://entityframework-plus.net/

Only problem if I set null to ImageByte2. Following error:

The implicit conversion of the nvarchar data type into varbinary (max) is not allowed. Use the CONVERT function to perform this query

Now its I define ImageByte1 and ImageByte2 as null, it does update normally or ImageByte1 and ImageByte2 other than null also does update.

Any solution ?

Accepted Answer

The problem has already been corrected with the most up-to-date version.

Nuget: https://www.nuget.org/packages/Z.EntityFramework.Plus.EF6/




Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why