Brian
Brian

Reputation: 819

WCF Data Service reference in WPF Project in VS2017

I'm having issues adding a service reference to my WPF project in VS2017. The service itself is a WCF Data Service using EntityFramework (EntityFrameworkDataService). In VS2013 that I was using before, I didn't have any issues adding services to my WPF project. I upgraded to VS2017 last month, and recently made some changes to the WCF service and needed to refresh the reference in my WPF project. I couldn't seem to get it to refresh so I deleted the reference and started trying to re-add the reference and now I'm greeted with this error message:

The specified OData API cannot be added because OData APIs are now only supported with Connected Services.

For more information, please see: https://aka.ms/odatavsclientguidance

That provided link does not have any info regarding VS2017 setups. It recommends to use the 'OData Connected Service' extension but that extension does not support VS2017 (tried it but got a "not compatible" message). I also found the 'VS WCF Connected Service' extension for VS2017, but it doesn't appear to support WPF projects (or atleast I couldn't figure it out).

Has anyone ran into this issue with adding a WCF Data Service reference to a WPF project? Any other suggestions that I could try?

Upvotes: 6

Views: 2966

Answers (2)

pim
pim

Reputation: 12577

As TGRA so eloquently stated, the best bet for VS2017 at time of writing is to use the dataserviceutil.exe. To make things simpler for myself I do the following:

  1. In File Explorer, navigate to the datasvcutil.exe using the path as follows: %windir%\Microsoft.NET\{{YOUR_PROCESSOR_ARCHITECTURE}}\{{YOUR_FRAMEWORKVERSION}}

  2. Hold shift and right-click. Select Open Commandwindow here (or command prompt if you prefer.

  3. Now execute a datasvcutil.exe command like so for C#: datasvcutil /language:Csharp /out:{{PATH_TO_PROJECT}}/{{SERVICE_NAME}}.cs /uri:{{URL_TO_SERVICE}}.svc

  4. OR execute a datasvcutil.exe command like so for Visual Basic: datasvcutil /language:VB /out:{{PATH_TO_PROJECT}}/{{SERVICE_NAME}}.VB /uri:{{URL_TO_SERVICE}}.svc

And voila, you're done.

Upvotes: 4

TGRA
TGRA

Reputation: 191

I typically generate my clients via the DataSvcUtil.exe which is part of the .net framework

e.g.

"%windir%\Microsoft.NET\Framework\v4.0.30319\DataSvcUtil.exe" /dataservicecollection /version:2.0 /language:CSharp /out:c:\temp\DataService.cs /uri:http://localhost:16584/DataService/

The MSDN docs: https://msdn.microsoft.com/en-us/library/ee383989(v=vs.110).aspx

Upvotes: 5

Related Questions