I am creating a RESTful service using Web API and Entity Framework with OData endpoints. The Microsoft.AspNet.WebApi.OData and Microsoft.Data.OData and Microsoft.AspNet.OData packages seem to overlap, so I wasn't sure which one to use. What are the differences between them? What are the pros and cons of each?
1 Answer
Microsoft.AspNet.OData
is the one you'll most likely want to use for a new project. It sets up Web API to use the OData 4 protocol.
Microsoft.AspNet.WebApi.OData
is the older package for OData v1-3. It has a dependency on some of the core OData pieces from Microsoft.Data.OData
, which is the "ODataLib" package for OData v1-3. (The OData v4 version of this is Microsoft.OData.Core
, which is a dependency of Microsoft.AspNet.OData
.)
-
Hi, i'm playing around with webapi + odata and I was wondering why the package adds so many dependencies to the project ? Microsoft.AspNet.OData (OK.) Microsoft.Extensions.DependencyInjection Microsoft.Extensions.DependencyInjection.Abstractions Microsoft.OData.Core Microsoft.OData.Edm Microsoft.Spatial System.Collections System.Collections.Concurrent System.ComponentModel System.Diagnostics.Debug System.Globalization System.Linq System.Linq.Expressions System.Reflection System.Resources.ResourceManager System.Runtime.Extensions System.Threading System.Threading.Tasks– spiloteJul 20, 2017 at 14:13
-
@spilote: I imagine it's because the OData and Web API libraries use those other libraries. It's probably more noticeable now because .NET Core broke a lot of those pieces out into separate libraries, whereas they used to be automatically included as part of the Base Class Libraries. Jul 24, 2017 at 18:38
DefaultODataSerializerProvider
andODataResourceSerializer
to customize serialization, but the first class only exists inMicrosoft.AspNet.OData
, notMicrosoft.AspNetCore.OData
, while the second exists in both. I am terribly confused.