OData v3 Service Wizard
- 2 minutes to read
XPO provides the OData Service Wizard which creates a web service project implementing an OData Service that supports the OData Version 3.0 protocol and exposes an XPO model. The project can also include a visual data model that can be edited in the Data Model Designer.
To invoke the OData Service Wizard, use the DXperience v21.1 ORM OData Service‘s built-in project template in the DevExpress: Visual C# | WCF and DevExpress: Visual Basic | WCF categories.
The wizard displays the following window after selecting the template and clicking OK:
The ODataLib for OData package is downloaded automatically if you choose Download the latest version from NuGet. To use a specific installed version, select Use specific version and specify the version in the text box below. If the Use DXperience ORM Data Model Wizard checkbox is ticked, then the Data Model Wizard starts immediately after clicking OK.
You can try this functionality in the XPO Tutorials demo’s Transferring Data via WCF | XPO OData Service section (C:\Users\Public\Documents\DevExpress Demos 21.1\Components\WinForms\Bin\XpoTutorials.exe).
The DevExpress.Xpo.XpoDataServiceV3 class descendant represents the OData service. If the Data Model Wizard was not used to create a model from an existing database, the data layer needs to be configured manually in the static CreateDataLayer method.
The XpoDataServiceV3 does not support composite keys. This could cause the “The entity type ‘XXX’ does not have any key properties. Please make sure that one or more key properties are defined for this entity type.” error with the XPO OData v3 Service if you map your persistent class to a table or view with a multi-column key. We do not recommend using composite keys as they impose many limitations on the default functionality. Refer to the How to create a persistent object for a database table with a compound key article for more details.