Incorrect UInt64 ToString SQL generation #20433
Labels
area-type-mapping
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
type-bug
Milestone
LINQ query with UInt64.ToString() to MS SQL Server with lagre property value produces flawed SQL code leading to exception.
Steps to reproduce
Suppose simple entity:
with simple DbContext using
UseSqlServer()
.Add-Migration
results withLongProperty
asbigint
andULongProperty
asdecimal(20, 0)
.ModelSnapshot.BuildModel
Sample database has an least one row with
LongProperty
equals toInt64.MaxValue
andULongProperty
equals toUInt64.MaxValue
.Then query
produces
that leads to Microsoft.Data.SqlClient.SqlException "Arithmetic overflow error converting numeric to data type varchar.".
Note
Note that
produces
that works fine.
The problem is that for
ULongProperty
generated SQL query assumes 19 character length string, which is too short. Manual row SQL query replaced withVARCHAR(20)
works fine.Further technical details
EF Core version: 3.1.3
Database provider: Microsoft.EntityFrameworkCore.SqlServer v.3.1.3
Target framework: .NET Core 3.1
Operating system: MS Windows 10 1909
IDE: MS VS Community 2019 16.5.1
DB: MS SQL LocalDB 14.0.1000.169
The text was updated successfully, but these errors were encountered: