Export (0) Print
Expand All

How to: Manually Generate Client Data Service Classes (ADO.NET Data Services)

Note Note

This topic describes new functionality in ADO.NET Data Services that is available as an update to the .NET Framework version 3.5 Service Pack 1. You can download and install the update from the Microsoft Download Center.

ADO.NET 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 (ADO.NET 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 ADO.NET 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.

Note Note

Only the DataSvcUtil.exe tool can be used to generate client data classes that support data binding.

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 ADO.NET 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.

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:http://localhost:12345/Northwind.svc
    
    NoteNote

    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:http://localhost:12345/Northwind.svc
    
    NoteNote

    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:http://localhost:12345/Northwind.svc
    
    NoteNote

    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:http://localhost:12345/Northwind.svc
    
    NoteNote

    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 
    

Community Additions

Show:
© 2014 Microsoft