The field Pdf must be a string or array type with a maximum length of '4000'

entity-framework-6

Question

I'm struggling, trying to save a byte array to my database, using EF (code first), MVC.NET.

var bytes = File.ReadAllBytes(filePath);
myObjectToSave.Pdf = bytes;

The message I get is

The field Pdf must be a string or array type with a maximum length of '4000'.

The PDF is 20kb!

Research on SO shows a few things about strings, but in my case, my object is

public byte[] Pdf {get; set;}

I am already using an array!

I am using SQL CE but I don't understand what to do to solve this issue.

1
1
10/13/2018 12:11:21 PM

Accepted Answer

check the EF Model it should be simply that a property on the Entity you're updating has the Max Length attribute

same problem

MaxLength attribute : check here

make sure that field set to varbinary(max) in sql

1
10/13/2018 12:18:28 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow