Error comparing byte array of different size in primary key with Add or Update then SaveChanges #16888
Labels
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
Problem
I am unable to Add and/or Update multiple entity objects when there are byte array primary key columns and the data in those columns have different lengths.
Exception
Details
The primary key has a timestamp, blob and blob field (datetime, ip, source ip). Both columns in the database have blobs of 4 and 16 byte lengths from a previous data import. So it's either having the two columns being inserted be different lengths, or having existing data in the database that has blobs of different lengths from that which is being inserted. Either way I see no way to get at this compare method and change it which is frustrating.
Steps to reproduce
Attempt to insert two entity framework object with a primary key that has byte arrays. Set the byte arrays to different lengths in the two objects. Using sqlite provider but also reproduces with sql server.
Using latest .NET core 2.2 as of 2019-07-30.
Expected behavior
Different array lengths should compare just fine when multiple objects are Added or Updated, this seems like a serious bug.
Workaround
Calling SaveChanges for each individual object after each add/update seems to resolve the issue. Having them all Added or Updated without calling SaveChanges appears to be the source of the bug.
The text was updated successfully, but these errors were encountered: