I have what should be an easy question but I have been unable to find the answer myself.
I am using EF4 CTP-5 Code First Model with hand generated POCOs. It is processing string comparisons in generated SQL as
WHERE N'Value' = Object.Property
I am aware that I can override this functionality using:
[Column(TypeName = "varchar")]
public string Property {get;set;}
Which fixes the issue for that single occurrence and correctly generates the SQL as:
WHERE 'Value' = Object.Property
However, I am dealing with a VERY large domain model and going through each string field and setting TypeName = "varchar" is going to be very very tedious. I would like to specify that EF should see string as varchar across the board as that is the standard in this database and nvarchar is the exception case.
Reasoning for wanting to correct this is query execution efficiency. Comparison between varchar and nvarchar is very inefficient in SQL Server 2k5, where varchar to varchar comparisons execute almost immediately.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…