[英]Entity Framework uses nvarchar (max) when MaxLength is specified
I have specified a text field's MaxLength
as 4096 with EF fluent api in order to limit its length: 我已经使用EF流畅的api将文本字段的MaxLength
指定为4096以限制其长度:
this.Property(p => p.MyText).HasMaxLength(4096).IsRequired();
But for some reason in SQL Server, the column becomes nvarchar (max)
. 但由于某些原因,在SQL Server中,该列变为nvarchar (max)
。
Just for test if I specify 2048 to make sure that SQL Server gets updated 仅供测试,如果我指定2048以确保SQL Server得到更新
this.Property(p => p.MyText).HasMaxLength(2048).IsRequired();
And this way it is works. 这种方式是有效的。
So my queston why EF sets sql nvarchar (max)
when MaxLength(4096)
所以我的问题为什么EF在MaxLength(4096)
时设置sql nvarchar (max)
MaxLength(4096)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.