Comments (7)
Hello @Sashi13 ,
I should have known faster what is the possible cause of this issue.
You are currently using the Dapper Global Context Mapping instead of using an Instance Context Mapping
What this means is that the mapping keeps being modified in a concurrency scenario, which could impact options and mapping when executing the Bulk Insert.
If the mapping is always the same (or you use a mapper key for different mapping, that's perfectly fine to use the global context but somewhere that will only called once, so not in a method.
Could you try again by either:
- Make sure that the mapping is only done once if you are using the Global Context Mapping
- By using an Instance Context Mapping in your method
Let me know if the possible cause and solution are clear.
Best Regards,
Jon
from dapper-plus.
Hello @Sashi13 ,
Do you want your key to be generated or not? In your title, you specify BulkInsert doesn't generate primary key
, but you use the InsertKeepIdentity = true
option (to insert the identity value from your entity, so doesn't generate it).
I believe there is something we do not understand correctly in your request.
Is it possible to have more information or create a runnable project with the issue? It doesn’t need to be your project, just a new solution with the minimum code to reproduce the issue.
Best Regards,
Jon
from dapper-plus.
Thank you for the reply. Sorry I forgot to remove the InsertKeepIdentity option. Anyhow it still didn't fix my problem. The primary key is auto generated by mysql during insert. The problem happens when I try bulkinsert the dapper_item_serial primary key for the data is not auto generated by mysql (the primary key is set to auto increment) and it returns as 0 (exception is thrown during the insert I have attached the exception below). This only happens if multiple user submit the result to the backend at same time. If one user submit at different timestamp then everything runs as intended.
StackTrace:
at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at .(DbCommand , BulkOperation )
at .( , DbCommand )
at .Execute(List`1 actions)
at .(List`1 )
at Z.BulkOperations.BulkOperation.Execute()
at Z.BulkOperations.BulkOperation.BulkInsert()
at Z.Dapper.Plus.DapperPlusAction.Execute()
at Z.Dapper.Plus.DapperPlusActionSet`1..(Object )
at System.Collections.Generic.List`1.ForEach(Action`1 action) in /_/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/List.cs:line 554
at Z.Dapper.Plus.DapperPlusExtensions.AlsoBulkInsert[T](IDapperPlusActionSet`1 actionSet, String mapperKey, Func`2[] selectors)
at Z.Dapper.Plus.DapperPlusExtensions.AlsoBulkInsert[T](IDapperPlusActionSet`1 actionSet, Func`2[] selectors)
at Antz.Core.V2.Logics.Receiving.<>c__DisplayClass40_4.<UpdatePadiniPairingSerials_Retry>b__15() in D:\Projects\StandardIMS\ANTZ_IMS\Antz.Core\V2\Logics\Receiving.cs:line 8683
at Polly.ResiliencePipeline.<>c.<Execute>b__28_0(ResilienceContext _, Action state)
Exception:
Exception thrown: 'MySql.Data.MySqlClient.MySqlException' in MySql.Data.dll
Exception thrown: 'MySql.Data.MySqlClient.MySqlException' in MySql.Data.dll
Exception thrown: 'MySql.Data.MySqlClient.MySqlException' in MySql.Data.dll
Exception thrown: 'MySql.Data.MySqlClient.MySqlException' in MySql.Data.dll
Exception thrown: 'MySql.Data.MySqlClient.MySqlException' in Z.Dapper.Plus.dll
Exception thrown: 'MySql.Data.MySqlClient.MySqlException' in Z.Dapper.Plus.dll
from dapper-plus.
Hello @Sashi13 ,
My developer tried, but everything worked as expected.
Having a project that reproduces this issue will surely ensure us that we have the same configuration as you. You can send it in private here: [email protected]
Best Regards,
Jon
from dapper-plus.
Hi @JonathanMagnan,
I have sent the project file to the specified email. Sorry for the delay.
Thank you
from dapper-plus.
Hello @Sashi13,
Since our last conversation, we haven't heard from you.
Did the solution proposed work?
Let me know if you need further assistance.
Best regards,
Jon
from dapper-plus.
Hi sorry for late reply. Yeah it did fix the issue. Thank you.
from dapper-plus.
Related Issues (20)
- A transport-level error for NVarchar(max) column when using auditing HOT 7
- Received an invalid column length from the bcp client for colid HOT 3
- Set ColumnSynchronizeDeleteKeySubsetExpression without .Entity<Whatever>()? HOT 4
- IndexOutOfRangeException on BulkMerge operations HOT 1
- ILogger not logging, but Console.WriteLine works? HOT 3
- Configure Merge for concurrency handling HOT 3
- Ids not coming back after first BulkInsert HOT 4
- Update trigger on target table causes BulkMerge to fail HOT 3
- Feature Request - suppress update if nothing changed. HOT 2
- Support for Sybase for Bulk Insert HOT 1
- Skip duplicate records on bulk insert HOT 5
- Avoid output HOT 7
- BulkInsert Postgres => An error occured while retrieving the InformationSchemaTable information. See the inner exception for details. HOT 4
- Dapper Plus can't map Id when use galera cluster HOT 3
- bulk insert very slow on mariadb version≥10.6.0 HOT 2
- PostgreSQL BulkMerge / BulkUpdate always returns all rows as update HOT 6
- Bulk Insert throws the exception 'Unknown data type' whenever inserting GUID to MySQL HOT 4
- Does this support DateOnly/TimeOnly? HOT 6
- Does this support Aot HOT 1
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 dapper-plus.