OData Service Wizard
- 2 min 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 v19.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 19.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 Service if you map your persistent class to a table or view with a multi-column key. This also applies to the XAF Mobile UI because it uses the XPO OData Service. 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.