With the recent release of Dynamics 365 (v9), it is now possible to have Virtual Entities.  These are entities that are not stored in the CRM database, but rather get their data from an OData API.  This allows you to, for example, use on-premises data in Dynamics 365 without having to directly integrate it.

First, we must setup a new Virtual Entity Data Source.  To do this, go to Settings > Administration > Virtual Entity Data Source.  Create a new one and set your URL.


With the Data Source configured, we can now create the Virtual Entity.  Create a solution (or use an existing one), and add a new Entity.  Note that there is now a Virtual Entity checkbox that you can check.  You must also choose the Data Source that was configured in the previous step.


After you Save the entity, there will be two fields created: ID and Name.  Before you can use the entity, you must configure the External Name of each of these fields.


Once you are done with this, Save and Publish the entity.  You can now navigate to the entity and it will fetch the data directly from the OData API we provided!


If you followed my previous blog post, you will notice that these are the two sample products we hardcoded into the API.  This is a pretty exciting new feature that opens up a lot of possibilities!

Microsoft is making it incredibly easy to create an OData API using ASP.NET Core.  All you have to do is create an ASP.NET Core project, add an ODataController and add some boilerplate code.

First, create a new ASP.NET Core Web Application project in Visual Studio -- choose the Empty template.  After it's been added to your solution, add the Nuget package Microsoft.AspNetCore.OData.  You may need to include prerelease packages (as of right now it's v7.0.0-beta2).

Let's create a model called Product.

We'll also create a very simple controller for it.

Note that you have to set the EnableQuery attribute and return an IQueryable for the $filter/$select query options to work.

Now, let's wire it up in our Startup.cs file and hit F5.

When we debug and run it, you'll see that we can query the API as a standards-compliant OData API!


Being able to easily create an OData API opens up all sorts of possibilities.  For example, we can easily create a web service that surfaces on-premises data as a Virtual Entity in Dynamics 365.