Git Product home page Git Product logo

Comments (9)

borisdj avatar borisdj commented on September 18, 2024

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.

BlowaXD avatar BlowaXD commented on September 18, 2024

It happens when I'm updating data from previously recovered entities.

I'll try the sample asap (hope tomorrow)

from efcore.bulkextensions.

BlowaXD avatar BlowaXD commented on September 18, 2024

Another thing, I'm using MSSQL for Linux, on Docker
https://hub.docker.com/r/microsoft/mssql-server-linux/
latest release

from efcore.bulkextensions.

borisdj avatar borisdj commented on September 18, 2024

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.

borisdj avatar borisdj commented on September 18, 2024

So far I have only tested it with MSSQL on Win 10.

from efcore.bulkextensions.

BlowaXD avatar BlowaXD commented on September 18, 2024

Hey !

I've got some more informations that I've found !
image

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.

borisdj avatar borisdj commented on September 18, 2024

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.

borisdj avatar borisdj commented on September 18, 2024

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.

BlowaXD avatar BlowaXD commented on September 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.