I am creating an OData v3 web API with the first Entity Framework 6.0 interface.
Everything works well, and I can do CRUD operations back to the api server.
However, I use spatial types, and some of my objects have DbGeometry properties. When I try to update / send an object of type DbGeometry from a client application (just a console application for tests), I get this DataServiceRequestException:
There is no constructor without parameters for this object.
It took me a while, but I defined the DbGeometry type as responsible. I already covered this topic here and made a custom JsonConverter where I applied the property:
[Required] [JsonConverter(typeof(DbGeometryConverter))] [Column("geometria")] public DbGeometry Geometria { get; set; }
This did not work. An object will not be deserialized on the api web server unless I remove the DbGeometry property.
I also tried changing the behavior of the global json serializer
var formatters = GlobalConfiguration.Configuration.Formatters; var jsonFormatter = formatters.JsonFormatter; jsonFormatter.SerializerSettings.Converters.Add(new DbGeometryConverter());
Also useless. I really need DbGeometry properties. What else can I do to get around this?
source share