user380689
user380689

Reputation: 1794

EF5 code first migrations byte[] column

I am trying to create a data model that will work on both SQL Server 2008/2012 and SQLCE4. The problem i have is with binary data columns.

SQLCE requires use of the 'image' column type, but this is deprecated in SQL Server 2012.

If I declare a property as just:

byte[] Content { get; set; }

that's fine in SQL Server but fails for SQLCE consequently if i declare it as:

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

it works for CE now, but not for SQL server!

Is there some way to get this to work for both?

Upvotes: 0

Views: 382

Answers (1)

ErikEJ
ErikEJ

Reputation: 41749

use [MaxLength]

That will work both for SQL Server and SQL Server Compact

Upvotes: 1

Related Questions