zzzprojects / Bulk-Operations

C# SQL Bulk Operations | High-performance C# bulk insert, update, delete and merge for SQL Server, SQL Azure, SQL Compact, MySQL, and SQLite.
https://bulk-operations.net
142 stars 34 forks source link

Issue in inserting the identiy #22

Closed tareq2 closed 6 years ago

tareq2 commented 6 years ago

Hi, I am trying to copy data from SQL server to Mysql server using the BulkOperation and i want to insert the identity column as it is in the Sql server but it is not working with me and the odd thing it is working in one of tables. All of the tables are the same on both of the databases and my code is very simple

bulk.ColumnMappings.Add("Id", "Id",true);
            bulk.UseLogDump = true;
            bulk.InsertKeepIdentity = true;
             bulk.InsertIfNotExists = true;
            bulk.BulkInsert(dr);
            string d= bulk.LogDump.ToString(); 

From the LogDump i can't see the id in the list of the fields. Any help is appreciated. Thanks

JonathanMagnan commented 6 years ago

Hello @tareq2 ,

Thank you for reporting, we will look at it tomorrow.

Which version of the .NET Framework are you using and MySql?

Best Regards,

Jonathan

tareq2 commented 6 years ago

I am using .Net 4.6.1 MySql.Data(6.9.8) MySql 5.6 or MariaDb latest

JonathanMagnan commented 6 years ago

Hello @tareq2 ,

The v2.13.18 has been released.

We added the support to InsertKeepIdentity to MySQL.

However be careful, it doesn't work like SQL Server due to MySQL limitation.

It seems that you can insert an identity value but the next value must be higher than the previous to work. So in fact, you can only specify the next identity value.

It's probably not exactly what you are looking for but let me know if that can work with your scenario.

Best Regards,

Jonathan

JonathanMagnan commented 6 years ago

Hello @tareq2 ,

This issue will be closed since it has been resolved.

Feel free to reopen it if you feel otherwise.

Best Regards,

Jonathan