web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

How to use OData connected services and how to reference it in .Net Application?

(0) ShareShare
ReportReport
Posted on by 206
Hi experts,

I am working on integration of OData data entities with .Net Console Application. I have successfully integrated OData data entities with Postman. Now, I am working on integration with .Net Application. I am following the following blog https://shootax.blogspot.com/2019/10/d365fo-data-integration-by-odata-part-1.html which in summary creates application on azure then register the app and provided the required permissions, then creates a library project by the name of  /AuthenticationUtility/ and creates /ClientConfiguration/, /OAuthHelper/ class in this project. Then creates another console application by the name of /ODataUtility/ project. He/She uses /OData v4 Client Code Generator/ but since I am working with Visual Studio 2019, I have used OData Connected Services instead of /OData v4 Client Code Generator/.
 
Now, I want to ask how to add reference of that OData Connected Service in my project to use it?

Here is the necessary link I found from the Microsoft website: 
https://learn.microsoft.com/en-us/odata/client/code-generation-tool

I am attaching the necessary screenshots as well below





I have the same question (0)
  • Martin Dráb Profile Picture
    237,679 Most Valuable Professional on at
    How to use OData connected services and how to reference it in .Net Application?
    I guess that the namespace of objects in your ODataUtility project is the same as the project name, i.e. ODataUtility.
     
    By the way, ODataUtility doesn't have to be runnable application, if you want to run another project (TestODataClient). ODataUtility should be a class library. But you can still use it even when you created it as a console app.
  • Arif Hussain Profile Picture
    206 on at
    How to use OData connected services and how to reference it in .Net Application?
    Sir Martin Dráb,

    Thank you for your prompt response.

    Do you mean I have to use like this in line 9? I am also getting error when I am using resource in line 19. 

  • Martin Dráb Profile Picture
    237,679 Most Valuable Professional on at
    How to use OData connected services and how to reference it in .Net Application?
    No, that's a namespace used by Microsoft. I don't assume you named your namespace the same. I believe you didn't set a namespace, therefore you got a namespace with the same name as your project, which is ODataUtility (not Microsoft.OData.ODataUtility).
     
    Inside Main(), type ODataUtility, add a dot (".") and see what namespaces or types you have under ODataUtility namespace.
  • Arif Hussain Profile Picture
    206 on at
    How to use OData connected services and how to reference it in .Net Application?
    Sir Martin Dráb,

  • Arif Hussain Profile Picture
    206 on at
    How to use OData connected services and how to reference it in .Net Application?
    Sir in the reference class which is in connected service I can see that the namespace is different.

  • Martin Dráb Profile Picture
    237,679 Most Valuable Professional on at
    How to use OData connected services and how to reference it in .Net Application?
    All right, used that namespace. I was merely guessing.
  • Arif Hussain Profile Picture
    206 on at
    How to use OData connected services and how to reference it in .Net Application?
    Sir Martin Dráb,
    I used using Microsoft.Dynamics.DataEntities; but still it's the same error that Dynamics does not exist in the namespace Microsoft. In addition, I haven't added any reference of ODataUtility as there is no any dll file which I did for AuthenticationUtility which is a library file. 
  • Martin Dráb Profile Picture
    237,679 Most Valuable Professional on at
    How to use OData connected services and how to reference it in .Net Application?
    You don't need a DLL - add a project reference instead.
     
    By the way, the project will produce binaries when you compile it. Because you used a console app project and not a class library, it'll produce an executable file (.exe) and not a library (.dll).
  • Arif Hussain Profile Picture
    206 on at
    How to use OData connected services and how to reference it in .Net Application?
    Sir Martin Dráb,

    I got it but I think there is some issue in OData connected services. I want to ask have you implemented this before. If yes, please can you share any blog where I can use this connected services easily. Plus, I am also confused about "OData Client Code Generator" and "OData Connected Service". Can I use "OData Client Code Generator" instead of OData connected services in Visual Studio 2019 or it is depreciated in Visual Studio 2019. 
  • Martin Dráb Profile Picture
    237,679 Most Valuable Professional on at
    How to use OData connected services and how to reference it in .Net Application?
    I think a better approach would be explaining your current problem. I have no solution for "there is some issue".
     
    But if you want to start from scratch, I'm sure you'll find a lot of examples on internet. Both for F&O (like this) and for .NET development in general, because developing a C# consuming an OData service isn't really about D365FO. It also means that a .NET a development forum may be a better place than this forum about Dynamics 365 Finance.
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 683 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 563 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 398 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans