Should all databases attributes(data types) be put to MAX?
I am just asking if it is a good practice to put attributes to MAX and then you limit them in the programming side. I have good knowledge about databases but I have ZERO knowledge about good practices. In this video I noticed the context creates a database with MAX varchars and then you have to limit it, but I am wondering what if I try to make my own database in sqlserver.
KRIS NIKOLAISEN52,654 Points
from Microsoft docs
If you use nchar or nvarchar, we recommend to:
- Use nchar when the sizes of the column data entries are consistent.
- Use nvarchar when the sizes of the column data entries vary considerably.
- Use nvarchar(max) when the sizes of the column data entries vary considerably, and the string length might exceed 4,000 byte-pairs.
Allan ClarkTreehouse Moderator 10,799 Points
To add on to Kris's answer, the best practice for this is to have the Entity Framework attribute mirror the database column as closely as possible. The video shows what is created by default with no attributes, then adjusts the code to show the effects of adding the attributes.