You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This bug appeared when we were upgrading a substantial existing system that uses EF Core, to .NET 6.0. The error appears as this exception:
System.TypeLoadException: 'Return type in method 'Castle.Proxies.SubRecordProxy.<Clone>$()' on type 'Castle.Proxies.SubRecordProxy' from assembly 'DynamicProxyGenAssembly2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is not compatible with base type method 'EFCoreBugDemo.SubRecord.<Clone>$()'.'
Start with the EFCoreBugDemoNet6 project. Running this under VS2022 will generate the exception shown above.
Note these three specific things in the example code, all of which appear to be necessary to reproduce the bug (and all of which are necessary for our own system):
Use of record as an entity type
Use of inheritance between record types
Use of LazyLoadingProxies
Then try the EFCoreBugDemoNet5 example. Note that the C# code is identical to the .NET 6 example. Surprisingly:
If you run this .NET 5 example under VS2019 it runs OK.
If you run this .NET 5 example project from VS2022 you get the same error as in the .NET 6 example.
This suggests to us that the source of the problem might be in the compilation process rather than the libraries per se. It looks to us as though Roslyn is creating the hidden Clone method on a record type differently in the latest version, such that it no longer works with EF Core.
As it stands it is impossible for us to use EF Core with .NET 6 (given the three requirements above).
The text was updated successfully, but these errors were encountered:
This bug appeared when we were upgrading a substantial existing system that uses EF Core, to .NET 6.0. The error appears as this exception:
System.TypeLoadException: 'Return type in method 'Castle.Proxies.SubRecordProxy.<Clone>$()' on type 'Castle.Proxies.SubRecordProxy' from assembly 'DynamicProxyGenAssembly2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is not compatible with base type method 'EFCoreBugDemo.SubRecord.<Clone>$()'.'
We have created two separate minimal reproducible examples of the problem here: https://github.com/NakedObjectsGroup/NakedObjectsFramework/tree/master/BugDemo
Start with the EFCoreBugDemoNet6 project. Running this under VS2022 will generate the exception shown above.
Note these three specific things in the example code, all of which appear to be necessary to reproduce the bug (and all of which are necessary for our own system):
record
as an entity typerecord
typesLazyLoadingProxies
Then try the EFCoreBugDemoNet5 example. Note that the C# code is identical to the .NET 6 example. Surprisingly:
This suggests to us that the source of the problem might be in the compilation process rather than the libraries per se. It looks to us as though Roslyn is creating the hidden
Clone
method on arecord
type differently in the latest version, such that it no longer works with EF Core.As it stands it is impossible for us to use EF Core with .NET 6 (given the three requirements above).
The text was updated successfully, but these errors were encountered: