TrackableEntities / TrackableEntities.Core

Change-tracking across service boundaries with .NET Core.
MIT License
74 stars 13 forks source link

Support for EF Core 6 #46

Closed N-Olbert closed 2 years ago

N-Olbert commented 2 years ago

Hello,

are there any plans to support EF Core 6?

Currently it seems that only EF Core 5 is fully supported, f. e. on EF Core 6 we get the following error message:

System.MissingMethodException: Method not found: 'Boolean Microsoft.EntityFrameworkCore.Metadata.IForeignKey.get_IsUnique()'.
at TrackableEntities.EF.Core.NavigationExtensions.GetRelationshipType(INavigationBase navigation)
at TrackableEntities.EF.Core.DbContextExtensions.<>c.<ApplyChanges>b__0_0(EntityEntryGraphNode node)
at Microsoft.EntityFrameworkCore.ChangeTracking.ChangeTracker.<>c.<TrackGraph>b__30_0(EntityEntryGraphNode`1 n)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityEntryGraphIterator.TraverseGraph[TState](EntityEntryGraphNode`1 node, Func`2 handleNode)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityEntryGraphIterator.TraverseGraph[TState](EntityEntryGraphNode`1 node, Func`2 handleNode)
at Microsoft.EntityFrameworkCore.ChangeTracking.ChangeTracker.TrackGraph[TState](Object rootEntity, TState state, Func`2 callback)
at Microsoft.EntityFrameworkCore.ChangeTracking.ChangeTracker.TrackGraph(Object rootEntity, Action`1 callback)
at TrackableEntities.EF.Core.DbContextExtensions.ApplyChanges(DbContext context, ITrackable item)
at EntitiesEFCore6.DataAdapterEfCore6.SaveEntities(List`1 entities)

For this concrete problem the reason is the following method: https://github.com/TrackableEntities/TrackableEntities.Core/blob/2d8ae52eb6c1b4662bc7390405a6e2e1dfaf0114/TrackableEntities.EF.Core/NavigationExtensions.cs#L16-L23

While the ForeignKey-property still exists within the INavigation-Interface, the IsUnique-Property does not! Looking at the IForeigenKey-Interface documentation reveals that the IsUnique-property was present in EF Core 5, but does no longer exist in EF Core 6.

tonysneed commented 2 years ago

@N-Olbert Thank you for raising the issue. We will address as part of the .NET 6 upgrade in #45.

samantha-letourneau commented 2 years ago

@N-Olbert @tonysneed According to this document, .NET 6 supports .NET Standard 2.1 : https://dotnet.microsoft.com/platform/dotnet-standard. The current version used .NET Standard 2.0.

Also, it's kind of confusing because I read that there is no version of .NET Standard that is compatible with .NET 6.0. Nevertheless, for urgent needs you can use this forked package compiled for .NET 6 : https://www.nuget.org/packages/TrackableEntities.EF.NET6/

Tony would you made an update to this repository ?

tonysneed commented 2 years ago

Good idea! Let me try …

N-Olbert commented 2 years ago

@samantha-letourneau @tonysneed Just for reference: .NET 6 supports .NET Standard 2.1, but EF Core 6 does not:

EF Core 6.0 requires .NET 6. EF Core 6.0 does not target any .NET Standard version; for more information see the future of .NET Standard. Link

This is also different to EF Core 5, which supported .NET Standard 2.1, as the following table indicates

EF Core 3.1 5.0 6.0
.NET & .NET Core 3.1 5.0 6.0
.NET Standard 2.0 2.1

Source

TLDR: I'm not sure if moving to .NET Standard 2.1 is enough, maybe it is required target .NET 6 directly

tonysneed commented 2 years ago

@N-Olbert You're right ... we'll need to port to .NET 6 for EF Core 6 compatibility. I'll get to work finalizing #45.

tonysneed commented 2 years ago

@N-Olbert I checked and IsUnique property still exists on IReadOnlyForeignKey interface.

tonysneed commented 2 years ago

Closed by #45. Included in release v6.0.0.