Batching through a table variable may not work for non-default collations
See original GitHub issue(copied from @seriouz’s comment at https://github.com/aspnet/EntityFramework/issues/6577#issuecomment-264244982)
I have a database with some columns collations set to be case sensitive. Now EF build its query with a temp table, but this temp table does not have the collation on the column so on the insert the database server throws an exception. Until there is a work-around i can not use ef because the regarding columns contain (case sensitive) guids.
I think @seriouz meant to say SaveChanges()
fails, as opposed to querying data.
A possible workaround is to disable batching in either the OnConfiguring()
method on the DbContext
class or on the AddDbContext()
method in Startup
:
optionsBuilder => optionsBuilder
.UseSqlServer(connectionString)
.MaxBatchSize(1);
cc @AndriySvyryd as FYI
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:9 (6 by maintainers)
Top Results From Across the Web
The Table Variable in SQL Server
The reason for this case is, the first INFORMATION_SCHEMA. COLUMNS view, and table variable executed in the same batch so we can get...
Read more >Azure SQL database table variable collation
Try using. DECLARE @resultingRoles TABLE ([MemberRoleName] NVARCHAR(256) COLLATE Latin1_General_CI_AS NOT NULL PRIMARY KEY).
Read more >Table Variable and Database Scope
Table variables have the scope of the batch or stored procedure they are run in. There is no need to drop the table...
Read more >T-SQL Table variable with case sensitive columns - collate ...
The reason I want to do this is because I have case sensitive information in my source table but when I insert it...
Read more >Best practices with Amazon Aurora MySQL
This topic includes information on best practices and options for using or migrating data to an Amazon Aurora MySQL DB cluster.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@seriouz As a workaround you can specify the collation as part of the store type:
Workaround: Save one parent entity at a time. It correctly saves related data in its properties.
I didn’t see this workaround mentioned anywhere, but it was very helpful for us.