Generating the Client Data Service Classes (WCF Data Services)
A data service that implements the Open Data Protocol (OData) can return a service metadata document that describes the data model exposed by the OData feed. For more information, see OData: Service Metadata Document. You can use the Add Service Reference dialog in Visual Studio to add a reference to an OData-based service. When you use this tool to add a reference to the metadata returned by an OData feed in a client project, it performs the following actions:
Requests the service metadata document from the data service and interprets the returned metadata.
Note
The returned metadata is stored in the client project as an .edmx file. This .edmx file cannot be opened by using the Entity Data Model designer because it does not have the same format an .edmx file used by the Entity Framework. You can view this metadata file by using the XML editor or any text editor. For more information, see the [MC-EDMX]: Entity Data Model for Data Services Packaging Format specification
Generates a representation of the service as an entity container class that inherits from DataServiceContext. This generated entity container class resembles the entity container that the Entity Data Model tools generate. For more information, see Object Services Overview (Entity Framework).
Generates data classes for the data model types that it discovers in the service metadata.
Adds a reference to the Microsoft.Data.Services.Client.dll assembly to the project.
Note
When the WCF Data Services 5.0 release is installed, the Add Service Reference tool will automatically add a reference to this new version of the client library instead of adding a reference to the System.Data.Services.Client.dll version that is included in the .NET Framework. If for some reason you need to instead use the previous version of the WCF Data Services client, you should manually add a reference to the .NET Framework version of this library. For more information, see How to: Manually Generate Client Data Service Classes (WCF Data Services).
For more information, see How to: Add a Data Service Reference (WCF Data Services).
The client data service classes can also be generated by using the DataSvcUtil.exe tool at the command prompt. For more information, see How to: Manually Generate Client Data Service Classes (WCF Data Services).
Client Data Type Mapping
When you use the Add Service Reference dialog in Visual Studio or the DataSvcUtil.exe tool to generate client data classes that are based on an OData feed, the .NET Framework data types are mapped to the primitive types from the data model as follows:
Data model type |
.NET Framework data type |
---|---|
Edm.Binary |
Byte[] |
Edm.Boolean |
|
Edm.Byte |
|
Edm.DateTime |
|
Edm.Decimal |
|
Edm.Double |
|
Edm.Guid |
|
Edm.Int16 |
|
Edm.Int32 |
|
Edm.Int64 |
|
Edm.SByte |
|
Edm.Single |
|
Edm.String |
For more information, see OData: Primitive Data Types.
See Also
Concepts
Quickstart (WCF Data Services)