paillave / Etl.Net

Mass processing data with a complete ETL for .net developers
https://paillave.github.io/Etl.Net/
MIT License
631 stars 89 forks source link

Bug--When I save an entity with a primary key of guid to the database using the EfCoreSave method, an error occurs, prompting me to "Cannot insert value NULL into column 'Id', table 'SimpleTutorial. dbo. Author'; columns do not allow null values. UPDATE fails." When I change the insertion mode to SaveMode.EntityFrameworkCore Successfully save #483

Open it-copilot4 opened 1 month ago

it-copilot4 commented 1 month ago

1

Example Code public class Author { public Guid Id { get; set; } public string Email { get; set; } public string Name { get; set; }

} protected override void OnModelCreating(ModelBuilder modelBuilder) { var authorBuilder = modelBuilder.Entity(); authorBuilder.ToTable(nameof(Author)); authorBuilder.HasKey(i => i.Id); authorBuilder.HasIndex(i => i.Email).IsUnique(); authorBuilder.Property(i => i.Id).HasDefaultValueSql("NEWID()"); authorBuilder.Property(i => i.Name).IsRequired(); authorBuilder.Property(i => i.Email).HasMaxLength(250).IsRequired();

} var authorStream = rowStream .Distinct("remove author duplicates based on emails", i => i.Author) // .Select("create author instance", i => new Author { Email = i.Email, Name = i.Author }) .EfCoreSave("save authors", o => o .Entity(i => new Author {Id=Guid.NewGuid(), Email = i.Email, Name = i.Author }) .SeekOn(i => i.Name) //.AlternativelySeekOn(i => i.Name) .WithMode(SaveMode.SqlServerBulk));

it-copilot4 commented 1 month ago

@paillave is this a bug of SaveMode.SqlServerBulk

Mourad57 commented 1 week ago

Hello,

for me its not saving at all when specifying SaveMode.SqlServerBulk It does with the other mode.

Im using the latest prerelease version.

@paillave Is this project abandoned or are you lacking help spomehow to make it progress ??

paillave commented 1 week ago

Hello, the project is not abandoned at all. I'm making essential maintenance for the moment. I'm planning a big chunk of essential changes for a version 3.0. The bulksave mode is by default you don't need to mention it explicitly. What is the result that is returned by the ExecuteAsync method? If it fails, you should have every information about the failure. Checking the result is documented on the website.

Mourad57 commented 1 week ago

Hi, good to know, waiting for 3.0 to come soon !

For me, it simply returns without issues/errors when bulk mode is specified. But no data is saved. It does save when specifying the other mode.

Mourad57 commented 1 day ago

Hi Steph,

there seem to be a package conflict when using etl.net from a .net 8 solution targeting microsoft.entityframeworkcore 8.0.6

thats the error

Method not found: 'System.Nullable`1 Microsoft.EntityFrameworkCore.Metadata.StoreObjectIdentifier.Create(Microsoft.EntityFrameworkCore.Metadata.IReadOnlyEntityType, Microsoft.EntityFrameworkCore.Metadata.StoreObjectType)'.

migrating etl.net to .net 8 and using latest versions of the above fixes it.

bulk saving works flawlessly after that

paillave commented 7 hours ago

We are working on net8 migration these days. Hopefully we will be able to release it soon.

Stéphane.


From: Mourad57 @.> Sent: Sunday, July 7, 2024 12:20:46 PM To: paillave/Etl.Net @.> Cc: Stéphane Royer @.>; Mention @.> Subject: Re: [paillave/Etl.Net] Bug--When I save an entity with a primary key of guid to the database using the EfCoreSave method, an error occurs, prompting me to "Cannot insert value NULL into column 'Id', table 'SimpleTutorial. dbo. Author'; columns do not a...

Hi Steph,

there seem to be a package conflict when using etl.net from a .net 8 solution targeting microsoft.entityframeworkcore 8.0.6

thats the error

Method not found: 'System.Nullable`1 Microsoft.EntityFrameworkCore.Metadata.StoreObjectIdentifier.Create(Microsoft.EntityFrameworkCore.Metadata.IReadOnlyEntityType, Microsoft.EntityFrameworkCore.Metadata.StoreObjectType)'.

migrating etl.net to .net 8 and using latest versions of the above fixes it.

bulk saving works flawlessly after that

— Reply to this email directly, view it on GitHubhttps://github.com/paillave/Etl.Net/issues/483#issuecomment-2212398935, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABDFY2GFRBNV47XJXCYFMB3ZLEI75AVCNFSM6AAAAABHSKRPZ6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMJSGM4TQOJTGU. You are receiving this because you were mentioned.Message ID: @.***>