Skip to content
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

Error when working with NetTopology inside deferred #806

Open
kurthamilton opened this issue Aug 9, 2024 · 3 comments
Open

Error when working with NetTopology inside deferred #806

kurthamilton opened this issue Aug 9, 2024 · 3 comments
Assignees

Comments

@kurthamilton
Copy link

Description

I recently added the Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite to work with the Point data structure, which represents the SQL Server geographic data type.

When I run a single query for an entity containing a Point property, the data is returned as expected.

When I run several queries together using EF+ deferred/future functions, I receive the error below.

Exception

An unhandled exception has occurred while executing the request.
System.IO.FileNotFoundException: 
Could not load file or assembly 'Microsoft.SqlServer.Types, Version=10.0.0.0, Culture=neutral, 
PublicKeyToken=89845dcd8080cc91'.
The system cannot find the file specified.
File name: 'Microsoft.SqlServer.Types, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'
   at System.Reflection.RuntimeAssembly.<InternalLoad>g____PInvoke|49_0(NativeAssemblyNameParts* 
__pAssemblyNameParts_native,
 ObjectHandleOnStack __requestingAssembly_native, StackCrawlMarkHandle __stackMark_native, 
Int32 __throwOnFileNotFound_native, 
ObjectHandleOnStack __assemblyLoadContext_native, 
ObjectHandleOnStack __retAssembly_native)

Example code

// Assume that Address is an entity containing a property with data type NetTopologySuite.Geometries.Point
// These queries would run successfully
var result1 = await Context.Set<Address>().Where(x => x.Id == 123).FirstOrDefaultAsync();
var result2 = await Context.Set<Address>().Where(x => x.Id == 456).FirstOrDefaultAsync();
// However, running as a deferred query will fail
var query1 = Context.Set<Address>().Where(x => x.Id == 123).DeferredSingleOrDefault().FutureValue();
var query2 = Context.Set<Address>().Where(x => x.Id == 456).DeferredSingleOrDefault().FutureValue();

var result1 = await query1.ValueAsync();
var result2 = await query2.ValueAsync();

Stack

  • Z.EntityFramework.Plus.EFCore v8.103.1
  • Microsoft.EntityFrameworkCore.SqlServer v8.0.7
  • Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite v8.0.7
  • MSSqlServer 14 + 16
  • .NET 8
@JonathanMagnan JonathanMagnan self-assigned this Aug 9, 2024
@JonathanMagnan
Copy link
Member

Hello @kurthamilton ,

Thank you for reporting.

We will look at it to see if we can quickly fix it.

Best Regards,

Jon

@JonathanMagnan
Copy link
Member

Hello @kurthamilton ,

We are currently getting an error that is different from yours. As we were not expecting an error about Microsoft.SqlServer.Types.

However, even if we find out why you get this error, the feature will still not work. We have some limitations in the way we created this feature. We need to eventually rewrite it to fix those limitations, but that's not currently in our short-term plans.

In short, we indeed have an issue with NetTopology for queries that use the Query Future, but it will not be fixed at this moment.

Best Regards,

Jon

@arex388
Copy link

arex388 commented Oct 21, 2024

I have been running into this issue since NTS became the default for geospatial data in EF Core years ago. I have had to "downgrade" to a separate standalone query for objects that have geography data types, along with my future queries. Frustrating because I can't use it together with the other future queries it belongs with. I have been waiting patiently for this to be fixed, and I'm hoping that it finally makes its way to the short-term to-do list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants