I am using efcore.sqlserver 1.0.1 with preview2 tools - I have a string property which in sql server is created as an nvchar(max) field. When I add a data annotation stringlength(100) to the property and add a new migration the migration does not alter the column at all.
However if I add a Required and StringLength annotation then the generated migration alters the column and shows ( .. maxLength: 100, nullable: false )
Why does it only do this if I change the nullable value?
I believe you need to use
MaxLengthAttribute instead of
This is probably because the
StringLength attribute has an option for minimum length, which is not supported natively by SQL, and therefore the
MaxLength attribute is a better fit for this use case.
The author found that this is a known issue for cases when the tool set has been upgraded from RC2 => RTM.