-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Labels
Description
Describe the Bug
Currently, configuring an EDM model with spatial properties is only supported via the ODataConventionModelBuilder
. Attempting to manually configure such a model using ODataModelBuilder
results in an error, making it impossible to use the non-convention-based builder for spatial types.
Steps to Reproduce
Define a data model with a spatial property:
namespace Sample.Models
{
public class Site
{
public int Id { get; set; }
public GeographyPoint Location { get; set; }
}
}
Attempt to manually configure the EDM model:
using Sample.Models;
using Microsoft.AspNetCore.OData;
using Microsoft.OData.ModelBuilder;
var builder = WebApplication.CreateBuilder(args);
var modelBuilder = new ODataModelBuilder();
var siteEntityType = modelBuilder.EntityType<Site>();
siteEntityType.HasKey(s => s.Id);
siteEntityType.Property(s => s.Location);
builder.Services.AddControllers().AddOData(
options => options.EnableQueryFeatures().AddRouteComponents(
modelBuilder.GetEdmModel()));
var app = builder.Build();
app.UseRouting();
app.MapControllers();
app.Run();
Expected Behavior
The EDM model should be configured successfully using ODataModelBuilder
, allowing spatial properties like GeographyPoint
to be registered manually.
Actual Behavior
An error is thrown when attempting to register the spatial property manually:

Additional Details
- The
Property
method being invoked has the following signature:
UntypedPropertyConfiguration Property(Expression<Func<TStructuralType, object>>)
- The generic overloads of
Property
, such as:
PrimitivePropertyConfiguration Property<T>(Expression<Func<TStructuralType, T?>>)
cannot be used becauseT
is constrained tostruct
, and spatial types likeGeographyPoint
do not satisfy this constraint. - To support manual configuration of spatial types, it may be necessary to introduce a new overload or extend the existing API to handle these cases explicitly.