简体   繁体   中英

C# EF6 Code First binary(16) column

When building a class and I want an nvarchar(255) I can decorate the property with:

[StringLength(255)]
public string Name { get; set; }

What can I do for a byte[] to make sure the column that gets created is a binary(16) in the database?

Thanks.

You would use the following:

[MaxLength(16)]
public byte[] SomeByteArray { get; set; }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM