We are excited to announce the public preview release of the ASP.NET Core OData Web API Template Pack. This template helps you create an ASP.NET Core Web API project with OData support, providing a streamlined setup for .NET 8.0 and above. The following preview release is now available on NuGet:
Key Features
- Support for .NET 8.0 and above: Easily create projects targeting the latest .NET versions.
- OData Query Options: Enable query options like
$filter
,$select
,$expand
,$orderby
, and$count
. - OpenAPI (Swagger) Support: Enable OpenAPI support for better API documentation.
- Batching Support: Allow OData batching in your project.
- Case Insensitive Routing: Enable case insensitive routing for controller/action property names.
Installation
To install the template, use the following command:
dotnet new install Microsoft.OData.WebApiTemplate
Usage
Using dotnet CLI
Create a new project using the template:
- Create template with default settings
dotnet new odata-webapi -n MyODataService1
- Specify .NET framework
dotnet new odata-webapi -n MyODataService2 -f net8.0
- Enable OData batching
dotnet new odata-webapi -n MyODataService3 --enable-batching true
- Enable query options
dotnet new odata-webapi -n MyODataService4 --query-option filter select expand
- Enable OpenAPI/Swagger
dotnet new odata-webapi -n MyODataService5 --enable-openapi true
- To view template options:
dotnet new odata-webapi --help
Using Visual Studio IDE
- Open the “Create a new project” dialog:
When you first open Visual Studio, the start window appears, and from there, you can select Create a new project.
- Select a template type
- On the
Create a new project
dialog, search forOData
orOData Web API
. - Select
ASP.NET Core OData Web API Template
and then select Next.
- On the
- Configure your new project:
The Configure your new project dialog has options to name your project (and solution), select a disk location, and more.
- Additional information dialog:
This includes options to select when creating an
AspNetCore OData Web API project
. It includes:- Framework: The target framework to use for the project.
- ODataQueryOptions: OData query options. You can multi-select all of them or specific options like
filter
,select
,expand
,orderby
, andcount
. Default is all of them selected. - EnableNoDollarQueryOptions: Whether or not to prefix OData system query options with ‘$’. Default is true.
- EnableDefaultODataBatch: Allowing OData batching. Default is false.
- EnableOpenAPI: Enables OpenAPI (Swagger) support. Default is true.
Select Create to create the new project.
- Build and run the project:
Build and run the application. Navigate to the
{Your-project-name}.http
to test some endpoints provided there.
Feedback
We value your feedback! Please report any issues or suggestions on our GitHub repository.
Thank you for trying out the ASP.NET OData Core Web API Template!
0 comments
Be the first to start the discussion.