New Unicode attribute available in Entity Framework Core 6

In Entity Framework Core 6 there is a new Unicode attribute which we can use to tell EF to map C# strings to non-Unicode columns without specifying the underlying DB type directly. Previously this is only possible via the Fluent API approach.

I have seen recommendations to make everything Unicode (eg. nvarchar in SQL Server) ‘just in case’, but I personally don’t like this design approach. Remember, a varchar takes up HALF THE SIZE of an nvarchar for an equivalent string. If you know for sure a column is ASCII SAFE using nvarchar is just wasteful… BUT… space is cheap.. that’s true but there can be performance implications too…

I’m not a DBA but the basic idea is that SQL Server stores data in 8k pages (in memory), the wider the columns are the less data can fit into one page before it needs to go to hard disk again, reading from disk will always be slower than reading from memory, how much slower?… who knows… all depends on I/O cost for particular server/disk etc.

Leave a Reply

Your email address will not be published. Required fields are marked *