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 36 forks source link

Bulk Synchronize not deleting rows on SQLite #61

Closed atilapoltronieri closed 3 years ago

atilapoltronieri commented 3 years ago

Hello.

I'm having a problem using the Bulk Synchronize with SQLite. I'm using the attachment files to do a bulk insert of one of them then use the bulk synchronizer with the other one. Those are the results that I got:

This scenario is working properly with SQL Server and MySql, the ones I tested locally. This seems to be a bug related only to SQLite.

testdata.xlsx updateTestData.xlsx

JonathanMagnan commented 3 years ago

Hello @atilapoltronieri ,

Thank you for reporting, we will look at this.

Best Regards,

Jon

JonathanMagnan commented 3 years ago

Hello @atilapoltronieri ,

The v3.0.28 has been released.

Could you look at it and let us know if everything is now working as expected for the BulkSynchronize under SQLite?

Best Regards,

Jon

JonathanMagnan commented 3 years ago

Hello @atilapoltronieri ,

Since our last conversation, we haven't heard from you.

Did you get the time to try v3.0.28?

Let us know if BulkSynchronize is now working correctly.

Looking forward to hearing from you,

Jon

atilapoltronieri commented 3 years ago

Sorry, I'm out of the office. I'll check it on monday.

JonathanMagnan commented 3 years ago

Hello @atilapoltronieri ,

Since our last conversation, we haven't heard from you!

Did you get the chance to try v3.0.28?

Let us know if BulkSynchronize is now working correctly.

Jon

atilapoltronieri commented 3 years ago

Sorry. You can mark it as done.

I'm on vacation for this week and they didn't let me in to test the scenario. I'll keep in touch if the scenario still fails.

Thank you for your hard work! Wish you the best.

JonathanMagnan commented 3 years ago

Hello again!

Don't hesitate to contact us once you give it a try!

Enjoy your vacation :)

Jon

JoseSalgadoPerez commented 3 years ago

Hi @JonathanMagnan , while Attila is on vacation I can help test, where can I get v3.0.28?

JonathanMagnan commented 3 years ago

Hello @JoseSalgadoPerez ,

You simply need to update the NuGet package to the latest one.

Here is the link to the NuGet package: https://www.nuget.org/packages/Z.BulkOperations/

Best Regards,

Jon

JoseSalgadoPerez commented 3 years ago

Hi @JonathanMagnan , We are using Z.EntityFramework.Extensions I understand that inside Z.Bulkoperations it works, so just to confirm, should we update the Z.EntityFramework.Extensions Nutget package and this issue will be resolved?

JonathanMagnan commented 3 years ago

Hello @JoseSalgadoPerez ,

Yes, exactly.

JoseSalgadoPerez commented 3 years ago

Hi @JonathanMagnan, I updated Z.EntityFramework.Extensions nutget package but it is still not working . I had different results with SQL Server and SQLite.

The new lines are inserted The lines with differences are updated The lines missing are not deleted Difference between SQLite   SQL Server

JonathanMagnan commented 3 years ago

Thank you, I will ask my developer to look at it.

JonathanMagnan commented 3 years ago

Hello @JoseSalgadoPerez ,

My developer tried a few scenarios but he never successfully reproduced your issue. The BulkSynchronize seems to work perfectly on our side.

Do you think you could provide us a runnable example that show this issue?

Here is one of the example my developer did:

using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Data.Sqlite;
using System.Text;

namespace lab.EFCore30.Sqlite
{
    class Request_BulkSynchronise
    {

        public static string nameBD = typeof(Request_BulkSynchronise).Name;

        public static void Execute()
        {
            using (var context = new EntityContext())
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();
            }

            var listBefore = new List<EntitySimple>();
            var listAfter = new List<EntitySimple>();

            // SEED  
            using (var context = new EntityContext())
            {
                for (int i = 0; i < 6; i++)
                {
                    context.EntitySimples.Add(new EntitySimple { ColumnInt = i });
                }

                context.SaveChanges();

                listBefore = context.EntitySimples.AsNoTracking().ToList();
            }

            // TEST  
            using (var context = new EntityContext())
            {
                var list = context.EntitySimples.Take(3).ToList();
                list.ForEach(x => x.ColumnString = "Update");
                list.Add(new EntitySimple { ColumnInt = 20 });
                context.BulkSynchronize(list);
            }

            using (var context = new EntityContext())
            {
                listAfter = context.EntitySimples.ToList();
                // break point here to compare listAfter and listBefore
            }
        }

        public class EntitySimple
        {
            public int ID { get; set; }
            public int ColumnInt { get; set; }
            public string ColumnString { get; set; }
        }

        public class EntityContext : DbContext
        {
            public DbSet<EntitySimple> EntitySimples { get; set; }

            protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
            {
                var builder = new SqliteConnectionStringBuilder
                {
                    DataSource = nameBD + @".db",
                    Cache = SqliteCacheMode.Default,
                };
                optionsBuilder.UseSqlite(builder.ConnectionString);

                base.OnConfiguring(optionsBuilder);
            }
        }
    }
}

Best Regards,

Jon

JonathanMagnan commented 3 years ago

Hello @JoseSalgadoPerez,

SInce our last conversation, we haven't heard from you.

Did you get the chance to look at the example provided?

Don't hesitate to provide a runnable example that shows this issue.

Looking forward to hearing from you,

Jon

JoseSalgadoPerez commented 3 years ago

Hi @JonathanMagnan

I apologize for my delay in responding, we solved the issue with the latest version, we had to get a new license to update the nuget package.

Thanks for your time.

José Salgado.

JonathanMagnan commented 3 years ago

Awesome @JoseSalgadoPerez !

We are glad to hear that the issue has been solved :)

Don't hesitate to contact us with any questions or further assistance,

Jon