How is it possible to use OData in .net core appli

2019-07-15 06:49发布

问题:

According to docs (http://odata.github.io/WebApi/#11-01-OData-V4-Web-API-Scaffolding) it is required to inherit from ODataController. I have installed package using nuget and still not able to inherit from that class. Does OData support .net core? Are docs obsolete?

回答1:

A possible duplicate of OData Support in ASP.net core

The docs link that you mentioned is targeting .NET Framework. For .NET Core support, please download the Microsoft.AspNetCore.OData NuGet Package from

https://www.nuget.org/packages/Microsoft.AspNetCore.OData

This package has a dependency on Microsoft.OData.Core which will also get installed automatically. Starting from version 7.2.0 the package is targeting .NET Standard 1.1.

Once the package is referenced, You should be able to inherit from ODataController. For further details please refer to the following video and links

https://www.towfeek.se/2017/01/08/odata-with-aspnet-core/

http://odata.github.io/odata.net/v7/#ODL-7.3.1

I hope this helps