question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug in SQL Server provider when using UTF8 collations

See original GitHub issue

I’ve encountered exceptions when using EF with SQL Server and configuring

  • the database and all column collations to be a UTF8 collation and
  • all columns to use varchar rather than nvarchar (as one should with UTF8 collations on SQL Server, somewhat counter-intuitively).

I’ve been doing this for a while now without obvious issues, but in a project that does some massive import of larger text portions some of the inserts fail with an exception:

SqlException: The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 7 ("@p8"): Data type 0xA7 has an invalid data length or metadata length.

This does not happen with the traditional nvarchar type, and it happens only in some (thankfully reproducible) circumstances.

I have reduced my import to a test case. See instructions to reproduce there.

Version information

SQL Server version: Microsoft SQL Server Developer (64-bit) 16.0.1050.5 on Windows EF Core version: 6.0.16 Database provider: Microsoft.EntityFrameworkCore.SqlServer Target framework: .NET 6.0 Operating system: Windows 11 IDE: Visual Studio 2022 17.5.2

Issue Analytics

  • State:open
  • Created 4 months ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jtheisencommented, May 11, 2023

Make sure you got the right branch.

0reactions
JRahnamacommented, May 12, 2023

I am able to reproduce the issue. with the repro. I will get back to you on this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Collation and Unicode support - SQL Server
Learn about collation and Unicode support in SQL Server. ... Collations that are used with character data types, such as char and varchar, ......
Read more >
cannot resolve collation conflict UTF-8 and Ascii
right-click/properties (SSMS 18.9.2) on database in SQL Server ... I notice that the error COLLATE using "AI" and your database according to ...
Read more >
Native UTF-8 Support in SQL Server 2019: Savior or False ...
Here are some issues that you might run into when using a UTF-8 Collation at either the Instance level or Database level. These...
Read more >
"Invalid data for UTF8-encoded characters" exception in ...
The column is set to varchar , with the database collation set to Latin1_General_100_CI_AS_SC_UTF8. Any idea what's going, or if a workaround is ......
Read more >
SQLServer DB is using a collation which is not case sensitive
When trying to migrate the HSQLDB to SQL Server the following message can be seen on the page: The database is not using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found