Comments (9)
The way InsertOrUpdate works is that first Temp table is Created into which data is Inserted and than Merged with main table. And at the end Temp table is Dropped, so it seems that you have problem with the last part dropping the table.
Does this happen every time, and do data get inserted or are changes rolled back?
Best would be if you could make test sample project where the issue would be reproducible, or to load source project of library, instead of nuget, into the Solution and try debugging it.
You are welcome, I'm glad it's useful.
from efcore.bulkextensions.
It happens when I'm updating data from previously recovered entities.
I'll try the sample asap (hope tomorrow)
from efcore.bulkextensions.
Another thing, I'm using MSSQL for Linux, on Docker
https://hub.docker.com/r/microsoft/mssql-server-linux/
latest release
from efcore.bulkextensions.
If you are doing only Update then use just BulkUpdate, no need for BulkInsertOrUpdate if you don't have new entities.
Secondly UseTempDb is False by default so no need for explicitly setting it to false.
Also if you have only one Bulk operation in method then explicit transaction is redundant.
from efcore.bulkextensions.
So far I have only tested it with MSSQL on Win 10.
from efcore.bulkextensions.
Hey !
I've got some more informations that I've found !
The exception thrown is not correct (at least, not deep enough), it looks like when a merge fails, the table is automatically dropped (A way to add a custom exception to handle it correctly ?)
The issue does not come from you but it can improve your awesome project !
:)
from efcore.bulkextensions.
Great you solved it.
I have just made a test for this situation(InsertOrUpdate-ing with 2 rows that have same Id in Source) and it gives me correct error:
Test failed
Message: _System.Data.SqlClient.SqlException
The MERGE statement attempted to UPDATE or DELETE the same row more than once. This happens when a target row matches more than one source row. A MERGE statement cannot UPDATE/DELETE the same row of the target table multiple times. Refine the ON clause to ensure a target row matches at most one source row, or use the GROUP BY clause to group the source rows.
I'm not sure why you first got Can Not Drop the Table error.
I have also checked and MsSQL does not Drop custom Temp tables on its own.
Maybe it could be something specific for MsSQL on Linux but can't say for sure.
from efcore.bulkextensions.
You can test with these scripts, that SQL Server does not do drop automatically.
First create EFCoreBulk Test DB: EFCoreBulkTestDB.sql
Next run this Sql script: EFCoreBulkTestSQL.sql
It should give correct error, then Refresh Database and check if Temp table have remained in DB.
from efcore.bulkextensions.
Sorry for the late reply, I was busy, i'll try it as soon as I arrive home (can't try it with my actual env)
from efcore.bulkextensions.
Related Issues (20)
- BulkInsertOrUpdateAsync performance questions HOT 3
- Using EF Core 8 Complex Property results in error "Sequence contains no matching element"
- When using PostgreSQL to batch insert DateTime.Now data, there might be a time offset.
- BulkExtensions determines target DbContext incorrectly when calls to different database servers in parallel HOT 1
- VULN: CVE-2024-32655 in Npgsql dependency HOT 3
- BulkInsertOrUpdate doesn't return Identity when no insert or update happen
- not present in the dictionary.
- can BulkInsert support my custom ValueGenerator for Id column HOT 1
- BulkSaveChangesAsync leaves tracked entities in state of "Added" even after successful save. HOT 2
- Spatial support in SQLite for Point
- BulkRead: System.NotSupportedException: 'Specified method is not supported.'
- BulkInsert produces sytanx error on PostgreSQL (version 6.x) HOT 1
- Bulk operation fails when owned type has enum member on PostgreSQL
- `SharedTypeEntity` don't work with bulk operations HOT 1
- [MySql/MariaDb] Insert an boolean type has invalid result (Always insert true in a bit column) HOT 3
- Question : Set value on shadow properties "on save" HOT 1
- Unable to cast object of type 'System.Int64' to type 'System.Nullable`1[System.Int32]' HOT 1
- PostgreSQL Table-Per-Hierarchy Inheritance Is Not Working HOT 1
- Truncate method with custom table name HOT 1
- BulkInsertAsync is assigning negative values to inserted entries' primary keys HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from efcore.bulkextensions.