Creating Data Entities: A Step-by-Step Guide

Rumman Ansari   Software Engineer   2024-08-23 10:47:07   930  Share
Subject Syllabus DetailsSubject Details
☰ TContent
☰Fullscreen

Table of Content:

General:

  • Whenever new build is deployed, it is necessary to do the refresh of data entity in Gold Environment. Please see the section
  • Any new data entity will be created in Dev Environment and it will be deployed along with the deployment of new build.

Step 1:

  • Create a D365 project in Visual Studio named DataEntityExample. To create a new entity, right-click the project and then click Add > New item. The Add New Item dialogue box opens.

Step 2 :

  • Select Data Entity, and then set the Name property to ItemSerialNumber. Then click the Add button. (example is taken as create data entity of ItemSerialNumber table).
Creation of Data Entities Image 1
Figure: Creation of Data Entities Image 1

Step 3:

  • In the Data Entity Wizard, all the properties will be defaulted except Primary datasource. Select InventSerial table as the primary datasource to export/import the item serial numbers.
  • Click the Next button.
Creation of Data Entities Image 2
Figure: Creation of Data Entities Image 2

Step 4:

  • Add fields to the new entity from the data source InventSerial as shown in the following screenshot. Click the Convert labels to field names checkbox to generate names from the existing labels. Note that the fields InventSerialId and ItemId are marked as mandatory, and these fields will be used as the natural key for the entity.
Creation of Data Entities Image 3
Figure: Creation of Data Entities Image 3

Step 5:

  • Click Finish. The newly created data entity and staging table are added to the project.
Creation of Data Entities Image 4
Figure: Creation of Data Entities Image 4

Step 6 :

  • In Solution Explorer, right-click on the ItemSerialNumber data entity node and then click Open. Set the Label property to Item Serial Numbers. This is the name that will get displayed in the data entity list.
  • To make the entity available in data management, the property Data Management Enabled should be set to Yes and the property Data Management Staging Table should be ItemSerialNumberStaging.
  • To make the entity available in an Odata scenario, the Public Collection Name and Public Entity Name will get defaulted, and the property Is Public should be set to Yes.
Creation of Data Entities Image 5
Figure: Creation of Data Entities Image 5

Step 7:

  • Now open the ItemSerialNumberStaging table in the designer. Staging tables are used in import/export scenarios to temporarily store the data being exported and imported. In many cases, staging tables are mapped 1:1 to an entity. Note that the first four fields (DefinitionGroup, ExecutionId, IsSelected and TransferStatus) are the standard fields of a data entity staging table. The table also contains the data fields we selected while creating the data entity. Note that the data entity relations will be created automatically.
Creation of Data Entities Image 6
Figure: Creation of Data Entities Image 6

Step 8:

  • In Solution Explorer, right-click the project, and then click Properties. Set Synchronize database on build property to True.
  • Note: Entities are created as views in Microsoft SQL Server, and staging tables also are added. Therefore, we must sync a database when we build entities.
  • Now build the project by going to the Visual Studio toolbar and clicking Build > Build Solution.
  • Verify the build doesn't contain errors.

Step 9:

Now we need to add this entity in the data management work space. Navigate to Work space | Data management | Data entities.

Add a new record as follows and save it. Now click on Validate:

 Add this entity in the data management work space

Step 10:

Let's try to import data into PacktVendTable using this new Data entity. Now go back to the Data management work space. Click on Import tile. Fill in the details as follows:

Import data into PacktVendTable using this new Data entity

Upload the Excel file that contains data. Now click on the Import button. You will get a notification once this import is done. To check, browse the table and check inserted data.

MCQ Available

There are 1 MCQs available for this topic.

1 MCQ