-
-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BulkMerge Error on DateTime upgrading from net5 to net6 #801
Comments
Hello @VittorioMorellini , Could you try if the issue also happens to the latest version of EFE for EF Core 6? https://www.nuget.org/packages/Z.EntityFramework.Extensions.EFCore/6.102.3 Do you think you could 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. You can send it in private here: [email protected] Best Regards, Jon |
Hi Jonathan, thank you for your answer. and the error is still happening. To recreate the issue it is very easy and the error appears if I execute: But if I execute: context.BulkMerge(new TEntity[] { entity }, options => options.IncludeGraph = true); There is a difference between: Which do I have to use??? I usually use the second release Best Regards |
Hello @VittorioMorellini , You can just use EF Plus already has a dependency on So in your case, you can just upgrade to https://www.nuget.org/packages/Z.EntityFramework.Plus.EFCore/6.102.3 instead Best Regards, Jon |
Hello @VittorioMorellini , Indeed, there is some difference in the behavior in the v5.x (until a specific version) and v6.x Before, the default value was skipped during the insert and update phase of the BulkMerge, but we fixed this problem to ensure we only skip property with a default value configuration during the insert phase. The IncludeGraph also has a breaking change in the version x.100.0.0. Prior to this version, the update part was also always ignored for a default value but is no longer ignored. I currently have a hard time explaining as this is the combination of both that makes it even worse to understand. With the latest version, you should be able to get the same behavior by using either Best Regards, Jon |
Hi Jon, I have problem during Insert, this solution can help me during Update statement but not during Insert statement completed with bulkMerge. try
{
ctx.BulkMerge(new TEntity[] { item }, options => options.IncludeGraph = includeGraph);
}
catch (Exception ex)
{
if ((long)item.GetType().GetProperty("Id").GetValue(item) == 0)
{
ctx.BulkInsert(new TEntity[] { item }, options => options.IncludeGraph = includeGraph);
}
else
{
ctx.BulkUpdate(new TEntity[] { item }, options => options.IncludeGraph = includeGraph);
}
} Or the other solution is to initialize the datetime with a right value. |
I am thinking to keep the technical debit that I hace and Stay to release dotnet5 because I don't like this problem and I am not sure of what happen with this workaround I found I am thinking to stay with EF core 5 and Z.EntityFramework.Extensions.EFCore 5.1.9 Vittorio |
Hello @VittorioMorellini , If you can provide a prototype project (starting a new project) that contains only your example and the behavior you want, we could look at it and provide you with the right solution for your requirements. You can send it privately here: [email protected] We can already reproduce this issue with the date, but I want to ensure my developer will give you the right answer to your exact scenario. Best Regards, Jon |
Hi Jon, I am going to work to a simple console application to reproduce the error Vittorio |
1. Description
Error executing BulkMerge with EFcore 6, it did not happen with bulkmerge in dotnet5
Error condition: EFcore 6.0.5, Z.EntityFramework.Plus.EFCore 6.16.1
Updating entity with DateTime equal 01/01/0001 raise an overflow error, I did not initialize datetime, and it raise an error while executin bulkmerge.
Database Sql Server 14.0.1000169
It did not happen on EFcore 5 and Z.EntityFramework.Extensions.EFCore 5.9.1
2. Exception
sqldatetime overflow. must be between 1/1/1753 12:00:00 am and 12/31/9999 11:59:59 pm
3. Fiddle or Project
4. Any further technical details
It happens the error while upgrading from EF core 5 and net5 :
TO
EF core 6.0.5 and net6, Plus.EFCore 6.16.1
Further technical details
The text was updated successfully, but these errors were encountered: