Reputation: 104692
Is there a way to set the length of a field in EF (6.1)?
I want the following property to be generated as char(2)
:
public string LanguageId { get; set; }
Upvotes: 4
Views: 4856
Reputation: 13354
You could combine TypeName
and StringLength
:
[Column(TypeName = "char")]
[StringLength(2)]
public string LanguageId { get; set; }
Within SQL Server it should generate a char(2)
column.
Upvotes: 8