Back to Devexpress

Implement a Data Model: Basics

expressappframework-402981-getting-started-in-depth-tutorial-blazor-define-data-model-and-set-initial-data-define-data-model-and-set-initial-data-with-ef-core-implement-a-data-model-basics.md

latest3.9 KB
Original Source

Implement a Data Model: Basics

  • Jul 30, 2025
  • 4 minutes to read

This lesson explains how to implement entity classes for your application and describes the basics of automatic user interface construction based on data.

During this lesson, you will do the following:

  • Add a simple entity class.
  • Display the entity class in the application’s navigation control.

Entity classes do not depend on the application UI. Implement them in a platform-independent module project. This way, other XAF or non-XAF applications can share entities.

Inherit your entity classes from the base persistent class BaseObject. The BaseObject class implements the IXafEntityObject and IObjectSpaceLink interfaces. This means that CRUD operations for the declared objects are available automatically and you don’t need to implement them in your code.

For additional information on these concepts, refer to the following topic: Views.

Step-by-Step Instructions

  1. Expand the MySolution.Module project and right-click the Business Objects folder. Choose Add | Class…. Specify Employee.cs as the new class name and click Add. Replace the auto-generated code with the following class declaration:

  2. Go to the MySolution.Module\BusinessObjects\MySolutionDbContext file and add the following property to the MySolutionEFCoreDbContext entity container class:

Propagate Data Model Structure Changes to the Database

Your application now contains data objects. This means that the application requires a database. You have the following options to choose from:

  • Use a DBMS to maintain the database (default option)

  • Use an in-memory database

Application Run

  1. Run the application. You can see that the UI did not change. To make the Employee item visible in the application’s navigation control, add the DefaultClassOptionsAttribute attribute to the corresponding class:

  2. Run the application. XAF generates a user interface that is based on the specified data structures. The List View displays the collection of objects of the Employee class. Since there are no objects of this type, the Employee List View is empty for now:

  3. Click the New button to invoke the Detail View for a new object of the Employee type. XAF renders the properties of the entity class as data fields. The Detail View contains editors for each data field.

Next Lesson

Extend the Data Model

See Also

Business Classes vs Database Tables

Built-in Business Classes & Interfaces

Ways to Add a Business Class

Generate EF Core Business Classes from an Existing Database for Blazor and WinForms Applications (Database First)