2

I noticed that Code First makes from every string a nvarchar data type in the SQL database. And the max amount of characters are set on MAX.

How can I influence this behavior?

Yustme
  • 6,125
  • 22
  • 75
  • 104

1 Answers1

1

Try this:

[MaxLength(10)]
public string PropertyName {get;set;}
Artless
  • 4,522
  • 1
  • 25
  • 40
  • Hi, what about nvarchar? What can I do against that? – Yustme Apr 21 '13 at 16:15
  • 1
    You could use `[Column(TypeName = "varchar")]`. If you want to set it globally to all string types, see this [page](http://stackoverflow.com/questions/5109170/ef-code-first-globally-set-varchar-mapping-over-nvarchar) – Artless Apr 21 '13 at 16:17