문제

My Code-First entity column is declared like this:

[Required, DataType("image")]
public byte[] Picture { get; set; }

Validations are turned off:

Configuration.ValidateOnSaveEnabled = false;

And is column type is still varbinary(4000).

When I try to save data, Entity Framework throws an exception:

Byte array truncation to a length of 4000.

How to declare that C# byte[] type should be mapped to image SQL type?

Versions:

SQL Server Compact 4

Entity Framework 5 RC

.NET Framework 4.0

도움이 되었습니까?

해결책

Use this attribute:

[MaxLength]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top