Further to my previous post about a bug with Entity Framework 1.0, I’ve have discovered another bug but this time due to its handling of varchars.
Let’s assume we’re using the following query:
var query = context.Orders.Where(o => o.Customer.Address.Country == "Australia");
If our Country column is a varchar Entity Framework will pass through our “Australia” string as an nvarchar parameter regardless of what we define in our SSDL!
Now has is this a bad thing you may ask? Well what this means is that even if we have an index on our country column, SQL Server will have to do an index scan rather than an index seek because it has to convert the nvarchar “Australia” down to a varchar and do the comparison across every row in the table.
Thankfully there is a workaround .
This problem has also been addressed in EF 4.0 as well.
