是否可以设置所有字符串字段的默认长度(除非我另有说明)?
目前,每次为了避免在数据库中的所有字符串列上使用nvarchar(max),都需要添加类似下面的内容:
modelBuilder.Entity<Game>().Property(x => x.YardLine).HasMaxLength(256);
是否可以设置所有字符串字段的默认长度(除非我另有说明)?
目前,每次为了避免在数据库中的所有字符串列上使用nvarchar(max),都需要添加类似下面的内容:
modelBuilder.Entity<Game>().Property(x => x.YardLine).HasMaxLength(256);
modelBuilder.Properties<string>().Configure(p => p.HasMaxLength(256));
modelBuilder.Properties<string>()
.Where(p => someCondition)
.Configure(p => p.HasMaxLength(256));
modelBuilder.Entity<EntityType>().Property(x => x.StringProperty)
.HasMaxLength(DifferentMaxLength);
modelBuilder.Properties<string>().Configure(p => p.HasMaxLength(256));