Set the column length to say 255 than use FluentValidation RuleFor to set the length at runtime in a class which inherits AbstractValidator. This of course means you validate before SaveChangess.
EF Core Alter Column size automatically
Benjamin Kempe
1
Reputation point
Is there any way, to resize the column to the needed length in runtime automatically?
for example: the column is a nvarchar(50), but the value to insert has a length of 80. Is it now possible to alter the column to nvarchar(80) by EF Core automatically?
Without EF Core we catch the Fieldlength-Exception and alter the columnsize to the needed length.