Replies: 4 comments 1 reply
|
ODP.NET will add NetTopologySuite support by the end of this year. Does NTS meet your Oracle Spatial app requirements? |
|
@Mganjirad ODP.NET EF Core Spatial support is available with Oracle.EntityFrameworkCore.NetTopologySuite on NuGet Gallery. It has some limited support for curved geometries. I've posted an EF Core sample using various Oracle spatial types. The Oracle SDO_GEOMETRY columns can be represented as NTS Geometry types in EF Core. Let me know if you have any other questions. |
|
@Mganjirad Here are the Oracle team's answers to your questions: QuestionIf EF Core + NTS integration attempts to materialize such geometries, AnswerIn Oracle Spatial datasets it is possible for a single SDO_GEOMETRY
The key reason is already well established: NetTopologySuite itself does
QuestionWill ODP.NET automatically linearize these curved geometries when AnswerNo. Automatic linearization is not performed, and raw curved geometries WorkaroundsSince curved geometries cannot be directly materialized into NTS types, the following approaches are typically used: 1. Linearize the geometry in SQL before EF reads itConvert curves to straight segments using SDO_GEOM.SDO_ARC_DENSIFY. var rows = ctx.SpatialCurves
.FromSqlRaw(@"
SELECT s.ID,
s.NAME,
SDO_GEOM.SDO_ARC_DENSIFY(s.GEOM, 0.005, 'arc_tolerance=0.05') AS GEOM
FROM SCOTT.SPATIAL_CURVES s")
.AsNoTracking()
.ToList();2. Use a database view with linearized geometryCreate a read-only view that exposes a linearized version of the CREATE OR REPLACE VIEW SCOTT.SPATIAL_CURVES_LINEAR AS
SELECT s.ID,
s.NAME,
SDO_GEOM.SDO_ARC_DENSIFY(s.GEOM, 0.005, 'arc_tolerance=0.05') AS GEOM
FROM SCOTT.SPATIAL_CURVES s;EF Core mapping examplemodelBuilder.Entity<SpatialCurf>(b =>
{
b.ToView("SPATIAL_CURVES_LINEAR", schema: "SCOTT");
b.HasKey(e => e.Id);
b.Property(e => e.Geom).HasColumnName("GEOM");
b.Property(e => e.Name).HasColumnName("NAME");
});3. Retrieve WKT/WKB instead of NTS geometryUse Oracle utilities like SDO_UTIL.TO_WKTGEOMETRY or Here is some sample code for the suggested workarounds. QuestionIn some scenarios, we need to read a curved geometry from the Oracle AnswerNo. While EF Core with Oracle.EntityFrameworkCore.NetTopologySuite can QuestionCurrent EF Core behaviorJust to make sure I understand: if I connect EF Core to an Oracle AnswerWhen using EF Core with Oracle.EntityFrameworkCore.NetTopologySuite, During database scaffolding, the column is typically represented as the In code-first scenarios, developers can use specific NTS derived types On a side note, there is a GitHub project to support curves in NTS. However, that project has not had a commit in almost 5 years. |
|
I truly cannot thank you and the Oracle team enough. Your detailed, precise, and incredibly helpful answers have been invaluable to me. I deeply appreciate the time you took and the thoughtful guidance you provided. Thank you. |

Uh oh!
There was an error while loading. Please reload this page.
Hello everyone,
I am currently developing spatial services on top of an Oracle Spatial database (tables with SDO_GEOMETRY columns), using .NET and Entity Framework Core as my ORM layer.
One of the challenges I am facing is that EF Core does not provide built-in support for Oracle Spatial functions such as SDO_ANYINTERACT, SDO_INTERSECTION, etc.
This forces me to use raw SQL queries (FromSqlRaw) for spatial operations, which raises concerns about performance and maintainability in scenarios with high request volume.
My design goals are:
My questions for the community are:
Any insights, best practices, or examples would be greatly appreciated.
Thanks,
All reactions