0 out of 2 rated this helpful - Rate this topic

How to: Add, Update, or Remove a WCF Data Service Reference

A service reference enables a project to access one or more WCF Data Services. Use the Add Service Reference dialog box to search for WCF Data Services in the current solution, locally, on a local area network, or on the Internet.

NoteNote

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.

To add a reference to an external service

  1. In Solution Explorer, right-click the name of the project that you want to add the service to, and then click Add Service Reference.

    The Add Service Reference dialog box appears.

  2. In the Address box, enter the URL for the service, and then click Go to search for the service. If the service implements user name and password security, you may be prompted for a user name and password.

    Note Note

    You should only reference services from a trusted source. Adding references from an untrusted source may compromise security.

    You can also select the URL from the Address list, which stores the previous 15 URLs at which valid service metadata was found.

    A progress bar is displayed when the search is being performed. You can stop the search at any time by clicking Stop.

  3. In the Services list, expand the node for the service that you want to use and select an entity set.

  4. In the Namespace box, enter the namespace that you want to use for the reference.

  5. Click OK to add the reference to the project.

    A service client (proxy) is generated, and metadata that describes the service is added to the app.config file.

To add a reference to a service in the current solution

  1. In Solution Explorer, right-click the name of the project that you want to add the service to, and then click Add Service Reference.

    The Add Service Reference dialog box appears.

  2. Click Discover.

    All services (both WCF Data Services and WCF services) in the current solution are added to the Services list.

  3. In the Services list, expand the node for the service that you want to use and select an entity set.

  4. In the Namespace box, enter the namespace that you want to use for the reference.

  5. Click OK to add the reference to the project.

    A service client (proxy) is generated, and metadata that describes the service is added to the app.config file.

The Entity Data Model for a WCF Data Services will sometimes change. When this happens, the service reference must be updated.

To update a service reference

  • In Solution Explorer, right-click the service reference and then click Update Service Reference.

    A progress dialog box is displayed while the reference is updated from its original location, and the service client is regenerated to reflect any changes in the metadata.

If a service reference is no longer being used, you can remove it from your solution.

To remove a service reference

  • In Solution Explorer, right-click the service reference and then click Delete.

    The service client will be removed from the solution, and the metadata that describes the service will be removed from the app.config file.

    Note Note

    Any code that references the service reference will have to be removed manually.

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
WCF service
Hi I have added my wcf service to my windows phone 7 application but now i get the Error: $0Custom tool error: Failed to generate code for the service reference. $0$0 $0 $0plz Help$0 $0
How to automatically update service reference
How to automatically update service reference in visual studio 2010 on every build (saved lot of time if you have multiple service refrences)
Service Reference not appearing - Solved
If "Add Service Reference" doesn't appear, open your *.csproj in Notepad/Textpad and replace the <ProjectTypeGuids> tag with this:
<ProjectTypeGuids>{14822709-B5A1-4724-98CA-57A101D1B079};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

Close and re-open your solution.

Worked like a champ for me.

-- Rap
Service reference for Windows Phone 7 App in VS2010 Ultimate RTM
Sorry, the version number of Visual Studio 2010 Ultimate is 10.0.30319.1 RTMRel. $0the only related work around I could find is  "http://colinizer.com/2010/04/14/quick-tip-add-odata-to-your-windows-phone-7-ctp-silverlight-application-in-vs2010-rc/".$0 $0But this doesnt help my case!$0
Service reference for Windows Phone 7 App
How do I add a service reference for a Windows Phone 7 application using Visual Studio 2010 Version 4.0.30319 RTMRel? $0$0 $0
Service reference for Windows Phone 7 App
The version of VS2010 on my system is 4.0.30319 RTMRel. I am trying to develop a Windows Phone 7 application using c#. $0I need to use the GeocodeService service for providing location information using Bing Maps. $0 $0However, in order to do this, I have to add a Service Reference and there isnt any option to add a service reference for a "Windows Phone 7 Application" project type.$0 $0Is this by design or a bug? Either way, what is my solution?$0
Add Service reference Option does not appear in menu
In my VS 2010 Ultimate instance, this menu option does not appear for some reason. However, all my peers do have this option when they open the same solution. Very bizarre... has anyone else seen this?

When my peer adds service references to my project, then I open it in my VS instance, the service references appear as empty folders and even though the underlying files (.xsd, .cs, etc) exist on disk, they do not load in VS for some reason.

I have reinstalled .NET 4.0 and Visual Studio 2010 twice to no avail.