Freigeben über


Generating the Data Service Client Library (WCF Data Services)

Important

WCF Data Services has been deprecated and will no longer be available for download from the Microsoft Download Center. WCF Data Services supported earlier versions of the Microsoft OData (V1-V3) protocol only and has not been under active development. OData V1-V3 has been superseded by OData V4, which is an industry standard published by OASIS and ratified by ISO. OData V4 is supported through the OData V4 compliant core libraries available at Microsoft.OData.Core. Support documentation is available at OData.Net, and the OData V4 service libraries are available at Microsoft.AspNetCore.OData.

RESTier is the successor to WCF Data Services. RESTier helps you bootstrap a standardized, queryable, HTTP-based REST interface in minutes. Like WCF Data Services before it, Restier provides simple and straightforward ways to shape queries and intercept submissions before and after they hit the database. And like Web API + OData, you still have the flexibility to add your own custom queries and actions with techniques you're already familiar with.

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 the Service Metadata Document section in the OData: Overview article. 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 [MC-EDMX]: Entity Data Model for Data Services Packaging Format.

  • 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 System.Data.Services.Client assembly to the project.

For more information, see How to: Add a Data Service Reference.

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.

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 Boolean
Edm.Byte Byte
Edm.DateTime DateTime
Edm.Decimal Decimal
Edm.Double Double
Edm.Guid Guid
Edm.Int16 Int16
Edm.Int32 Int32
Edm.Int64 Int64
Edm.SByte SByte
Edm.Single Single
Edm.String String

For more information, see the Primitive Data Types section in the OData: Overview article.

See also