How to: Manually Generate Client Data Service Classes (WCF Data Services)

WCF Data Services integrates with Visual Studio to enable you to automatically generate client data service classes when you use the Add Service Reference dialog box to add a reference to a data service in a Visual Studio project. For more information, see How to: Add a Data Service Reference (WCF Data Services). You can also manually generate the same client data service classes by using the code-generation tool, DataSvcUtil.exe. This tool, which is included with WCF Data Services, generates .NET Framework classes from the data service definition. It can also be used to generate data service classes from the conceptual model (.csdl) file and from the .edmx file that represents an Entity Framework model in a Visual Studio project.

The example in this topic creates client data service classes based on the Northwind sample data service. This service is created when you complete the WCF Data Services quickstart. Some examples in this topic require the conceptual model file for the Northwind model. For more information, see How to: Use EdmGen.exe to Generate an Entity Data Model (Entity Framework). Some examples in this topic require the .edmx file for the Northwind model. For more information, see .edmx File Overview (Entity Framework).

To generate C# classes that support data binding

  • At the command prompt, execute the following command without line breaks:

    "%windir%\Microsoft.NET\Framework\v3.5\DataSvcUtil.exe" /dataservicecollection /version:2.0 /language:CSharp /out:Northwind.cs /uri:https://localhost:12345/Northwind.svc
    

    Note

    You must replace the value supplied to the /uri: parameter with the URI of your instance of the Northwind sample data service.

To generate Visual Basic classes that support data binding

  • At the command prompt, execute the following command without line breaks:

    "%windir%\Microsoft.NET\Framework\v3.5\DataSvcUtil.exe" /dataservicecollection /version:2.0 /language:VB /out:Northwind.vb /uri:https://localhost:12345/Northwind.svc
    

    Note

    You must replace value supplied to the /uri: parameter with the URI of your instance of the Northwind sample data service.

To generate C# classes based on the service URI

  • At the command prompt, execute the following command without line breaks:

    "%windir%\Microsoft.NET\Framework\v3.5\DataSvcUtil.exe" /language:CSharp /out:northwind.cs /uri:https://localhost:12345/Northwind.svc
    

    Note

    You must replace the value supplied to the /uri: parameter with the URI of your instance of the Northwind sample data service.

To generate Visual Basic classes based on the service URI

  • At the command prompt, execute the following command without line breaks:

    "%windir%\Microsoft.NET\Framework\v3.5\datasvcutil.exe" /language:VB /out:Northwind.vb /uri:https://localhost:12345/Northwind.svc
    

    Note

    You must replace value supplied to the /uri: parameter with the URI of your instance of the Northwind sample data service.

To generate C# classes based on the conceptual model file (CSDL)

  • At the command prompt, execute the following command without line breaks:

    "%windir%\Microsoft.NET\Framework\v3.5\datasvcutil.exe" /language:CSharp /in:Northwind.csdl /out:Northwind.cs
    

To generate Visual Basic classes based on the conceptual model file (CSDL)

  • At the command prompt, execute the following command without line breaks:

    "%windir%\Microsoft.NET\Framework\v3.5\datasvcutil.exe" /language:VB /in:Northwind.csdl /out:Northwind.vb
    

To generate C# classes based on the .edmx file

  • At the command prompt, execute the following command without line breaks:

    "%windir%\Microsoft.NET\Framework\v3.5\datasvcutil.exe" /language:CSharp /in:Northwind.edmx /out:c:\northwind.cs 
    

To generate Visual Basic classes based on the .edmx file

  • At the command prompt, execute the following command without line breaks:

    "%windir%\Microsoft.NET\Framework\v3.5\datasvcutil.exe" /language:VB /in:Northwind.edmx /out:c:\northwind.vb 
    

See Also

Tasks

How to: Add a Data Service Reference (WCF Data Services)

Reference

WCF Data Service Client Utility (DataSvcUtil.exe)

Concepts

Generating the Data Service Client Library (WCF Data Services)