artiomchi / FlexLabs.Upsert

FlexLabs.Upsert is a library that brings UPSERT functionality to common database providers for Entity Framework in their respective native SQL syntax
MIT License
515 stars 81 forks source link

.NET 6.0 support #116

Closed rlightner closed 2 years ago

ezarzone commented 2 years ago

+1

Karql commented 2 years ago

Have you tried 6.0.0-preview5? https://www.nuget.org/packages/FlexLabs.EntityFrameworkCore.Upsert/6.0.0-preview5

For me it's works.

rlightner commented 2 years ago

That's what I'm using currently, but official .NET 6.0 support would be nice

hsinyu-chen commented 2 years ago

+1

khanhna commented 2 years ago

Just for some breaking change if no one notice:

ModelExtensions.FindEntityType method seems no longer exists in EF Core 6. And causing exception for some operations depend on it (likeupsert). I was just trying to make it a shot on MySql, not testing for other kind of databases.

rsr-maersk commented 2 years ago

There appears to be a breaking change on Npgsql for timestamp (i.e datetime) https://www.npgsql.org/doc/types/datetime.html

Datetimes as Unspecified need to be timestamp Datetimes as Local / Utc need to be timestampz

I have converted to timestampz, but even though my Datetimes are in UTC format they appear in the DB as local The issue is not apparent in EF Core SaveOrUpdate();

If Datetime property is Unspecified, then the Datetime is unfortunately not timestamp type

Soooo, looks like kind is being ignored for pg when generating sql.. This will be an issue later for many... FYA :-)

@artiomchi can you point me in the correct direction?

andrewlock commented 2 years ago

Another breaking change in 6.0 - the signature for GetServiceProviderHashCode() has changed. It now returns an int, not a long. This causes a runtime exception when using EF Core 6. See this description for more details

rsr-maersk commented 2 years ago

There appears to be a breaking change on Npgsql for timestamp (i.e datetime) https://www.npgsql.org/doc/types/datetime.html

Datetimes as Unspecified need to be timestamp Datetimes as Local / Utc need to be timestampz

I have converted to timestampz, but even though my Datetimes are in UTC format they appear in the DB as local The issue is not apparent in EF Core SaveOrUpdate();

If Datetime property is Unspecified, then the Datetime is unfortunately not timestamp type

Soooo, looks like kind is being ignored for pg when generating sql.. This will be an issue later for many... FYA :-)

@artiomchi can you point me in the correct direction?

This is no longer an issue with npgsql 6.0.2

rsr-maersk commented 2 years ago

GetServiceProviderHashCode

@andrewlock. r u sure it is a problem? i can only find GetServiceProviderHashCode on ExtensionInfo : DbContextOptionsExtensionInfo

EfCore still has it as a long

So if EFCore change, there is an issue

image

image

no build issue for efcore latest, and DbContextOptionsExtensionInfo overide

andrewlock commented 2 years ago

@rsr-maersk yes, it's definitely an issue. I was trying to upgrade an application to EF Core 6 last night, and I ran into this error at runtime. You can see here that the EF Core has changed it to an int:

https://github.com/dotnet/efcore/blob/41e6aaaf6216de904530de11b0bfd4af43fb13f7/src/EFCore/Infrastructure/DbContextOptionsExtensionInfo.cs#L73

rsr-maersk commented 2 years ago

@andrewlock yes, after i updated the packages in the flex, issue arises, sorry, my bad

rsr-maersk commented 2 years ago

@andrewlock , what do you think? https://github.com/rsr-maersk/FlexLabs.Upsert/commit/1d15d3e1c2e50e5224fce1c30ef30c21285757fd

andrewlock commented 2 years ago

yes, after i updated the packages in the flex, issue arises, sorry, my bad

No problem! 🙂

what do you think? rsr-maersk@1d15d3e

Looks good to me! 👍 Thanks! :shipit:

rsr-maersk commented 2 years ago

@andrewlock also issue with AddEntityType :-/

artiomchi commented 2 years ago

Big thanks to @rsr-maersk for setting up the groundwork for the 6.0 change!

Also for flooding my mailbox with notifications, so that I got some time to finally release this!

I just pushed the change live and the new package can be found in NuGet!