EntityFramework.Utilities icon indicating copy to clipboard operation
EntityFramework.Utilities copied to clipboard

Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_CI_AS" in the equal to operation.

Open chrislarabell opened this issue 7 years ago • 3 comments

Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_CI_AS" in the equal to operation.

When my server collation is set to a different collation than the database, I get this error when using .UpdateAll(...); When creating the temp table, I think the table is using the server default rather than the database default. I am not an SQL expert, but I will look into it.

My workaround is just changing the server collation to match my database (this is a development server with a db I restored from another SQL server).

chrislarabell avatar Jul 09 '18 16:07 chrislarabell

I'm no SQL expert either. I don't have much experience with collations.

If you can figure out what needs to be changed I'm happy to accept the pull request.

RudeySH avatar Jul 09 '18 18:07 RudeySH

I figured it out. UpdateAll creates a temporary table, and all temporary tables use the default collation of tempdb instead of your own database. I guess UpdateAll could be rewritten so that it specifies the collation of each string column when creating the temporary table, but the problem is that EFUtilities (or Entity Framework in general) does not know what a database's default collation is.

RudeySH avatar Dec 12 '19 13:12 RudeySH

The latest version, 1.0.11, will ensure that the default database collation is used for *char columns in temporary tables. However, if you're not messing with the default collation, but instead using specific collations on specific columns, there will still be issues.

RudeySH avatar Apr 10 '20 15:04 RudeySH