Is it possible to set default length of all string fields (unless I say otherwise)? At the moment it really bugs me to go and add something like
modelBuilder.Entity<Game>().Property(x => x.YardLine).HasMaxLength(256);
to each and every string field, just to avoid having nvarchar(max) on all my strings columns in the database.
You can use something called Custom Code First Conventions, but only if you're using Entity Framework 6+.
As @ranquild mentions, you can use
to configure the default maximum length for all string properties. You can even filter which properties to apply your configuration to:
Finally, any configuration on the entity type itself would take precedence. For example: