Why does code first/EF use 'nvarchar(4000)' for strings in the raw SQL command?

后端 未结 2 405
野趣味
野趣味 2020-12-19 06:43

Essentially I have a table with zip codes in it. The zipcode field is defined as \'char(5)\'. I\'m using code first, so I\'ve put these attributes on my ZipCode property:

相关标签:
2条回答
  • 2020-12-19 07:13

    Have you tried using the MaxLength attribute? This article gives a decent summary of how the various data annotation attributes are interpreted by EF.

    0 讨论(0)
  • 2020-12-19 07:25

    This is to take advantage of auto parameterization. The following article explains the general concept as well as why specifically nvarchar(4000) is used.

    http://msdn.microsoft.com/en-us/magazine/ee236412.aspx

    0 讨论(0)
提交回复
热议问题