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

Npgsql.PostgresException (0x80004005): 42883: function st_contains(deployment.geometry, deployment.geometry) does not exist #3155

Open
flyinseal opened this issue Apr 17, 2024 · 4 comments

Comments

@flyinseal
Copy link

Hi,

I want to query by using postgis extension. I can execute the function in postgresql database. But i fail in .net core project. This is used in an ASP.NET Core 8 application.

Referenced packages:
image

Program.cs
image

add extension in DbContext
modelBuilder.HasPostgresExtension("postgis");
entity
image

generate geometry object named as region where is used in method in repository
image

query in repository
var query = GetQueryable()
.Include(e => e.Locations)
.ThenInclude(e => e.PowerUnits)
.WhereIf(region != null, e => e.PowerUnits.Any(p => region!.Contains(p.Coordinates)));

error:
image

Is there something wrong in my code? Could you kindly please help me?

@roji
Copy link
Member

roji commented Apr 17, 2024

Can you please submit a minimal, runnable project or code sample that shows the problem happening? It's difficult to reconstruct a problem from a bunch of snippets and screenshots as above.

@flyinseal
Copy link
Author

Of course!

generate geometry parameter in service
image

call repository to query
image
even i use the native sql to query, but it doesn't work

DbContext
image
this extension is used in a new schema under the database named as deployment

Related Entity
image

Program.cs
image

This is all the codes related with this issue.
Besides, I have already executed below sql in database.
image
the last sql can be executed in database and cannot be executed through codes. same error like "ST_Point doesn't exist"
image

@flyinseal
Copy link
Author

I probably find the reason. However, I don't know how to solve it with EF core. I need to call the function under the schema "deployment". But the generated SQL doesn't include the "deployment" schema! Am I right? If so, how to specify the schema when I use the contains or within method.
I already add default schema in DbContext like below:
image

image

@roji
Copy link
Member

roji commented Apr 18, 2024

@flyinseal as a general rule, please don't post screenshots of code when reporting issues. As the maintainer, there's very little I can do with screenshots - I can't copy and paste your code, and it's frequently also very hard to actually read it (because the text is very small). Please go through the effort of actually producing a minimal, runnable code sample - like a simple console program, that, when executed, produces the problem.

I'm asking for this since I'm currently unable to reproduce your problem. And in 90% of cases, when users actually make the effort of creating a minimal repro, they run into some issue in their own code which caused the problem.

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

No branches or pull requests

2 participants