-
Notifications
You must be signed in to change notification settings - Fork 53
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
Using NodaTime in EF Core yield InvalidCastException in EF6 #181
Comments
Which version of Npgsql are you using (the ADO, not EF Core provider)? This sounds like npgsql/npgsql#2439 which was fixed in Npgsql 4.1.5 |
According to my lock file and file explorer, I'm on version 4.1.8. Interestingly the problem only surfaces when I actually model my EF Core class to use a Nodatime type. |
Can you please submit a minimal code sample, i.e. a small project with both EF Core and EF6 in use, which reproduces this problem? |
@roji Sure! Npgsql1704.zip |
OK, I can see the problem now - EF6 uses a special legacy mechanism to read values from NpgsqlDataReader. Instead of using generic While it may be possible to continue hacking the ObjectResultTypes mechanism to make EF6 work, the EF6 provider is now archived and not receiving significant attention - so we probably won't be able to fix this. If you must use both EF6 and EF Core, I'd recommend not using the NodaTime plugin for now, until the entire application can be moved to EF Core. |
I'm writing an application that's in the process of migrating to .NET 5 / Core / EF Core. However as most of the projects are targeting .NET Framework, this change will take some time. In the interim, we're writing new projects in EF Core 3.1, while the existing projects continue to work on EF6.
NodaTime isn't being used for the entities in the EF6 project (just DateTimeOffset / DateTime). However after adding NodaTime to the EFCore project, querying EF6 yields a
InvalidCastException
on the following lines: https://github.com/npgsql/npgsql/blob/613f095dede08f89a596c4360a6f3d8477050688/src/Npgsql/NpgsqlDataReader.cs#L1641-L1643.The text was updated successfully, but these errors were encountered: