Search code examples
c#entity-framework-6ef-code-firstrazor-pages

Using MaxLength attribute to specify NVARCHAR(MAX)


Using code-first data annotations, is it possible to use the [MaxLength()] attribute to specify a string column should be NVARCHAR(MAX)?

It doesn't appear to support this.


Solution

  • If you don't use the [MaxLength()] attribute at all on your property, it'll create a column as NVARCHAR(MAX) by default I believe