Finally OData 7.x supports and ASP.NET Core 2.x

Finally we can create OData (v4) services using ASP.NET Core.

My first impression, it’s ok, plus it has extra features.

Use my startup project, on Github as a sample. (It’s tricky to forget to enable features like Filter, otherwise you’ll and up with :

value":"The query specified in the URI is not valid. The property 'Id' cannot be used in the $filter query option."}

So, this is the Configure section

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
           if (env.IsDevelopment())
           var builder = new ODataConventionModelBuilder(app.ApplicationServices);
           app.UseMvc(routeBuilder =>
               routeBuilder.MapODataServiceRoute("ODataRoute", "odata", builder.GetEdmModel());
               // Work-around for #1175

           } ) ;

To get PATCH and POST working, we need the [FromBody] Attribute like here

public async Task Post([FromBody] Car newCar)


The sample, is downloadable here (ASP.NET-Core-With-Odata-7)

blog comments powered by Disqus