Friday, 3 May 2013

EF casting nchar to nvarchar

Weird glitch to watch out for in EF codefirst approach, where a string property defined in model which SQL Server automatically presumes is an nvarchar. But which actually is a varchar in the database. Since these are coercible, Entity Framework decided to coerce the type under the covers....

Performance Eater: Casting nchar to nvarchar
Performance Eater: Casting nchar to nvarchar