We are upgrading our code base from EF6.2 to EF Core 2.2, our team discovered that the default value of string based Identity key will generate a primary key column with
nvarchar(128)
in EF 6.2 (SQL Server) nvarchar(450)
in EF Core 2.2 (SQL Server)What is the reason behind this decision?
SQL Server allows indexes up to 900 bytes. Characters in an nvarchar are 2 bytes. 2 * 450 = 900. We (the EF team) were worried about primary keys on multiple columns in EF6. In EF Core, we realized only specified characters are indexed ("var" is for varying length) so we could go all the up to 450 and it would still work so long as the total characters across all columns in the key were less than 450.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With