Add a Class from the Business Class Library (EF 6)

  • 2 minutes to read

In this lesson, you will learn how to use business classes from the Business Class Library as is. For this purpose, you will add the Event business class to the application.


Before proceeding, take a moment to review the Inherit from the Business Class Library Class (EF 6) lesson.

  • Register the Event and Resource classes in DbContext. Edit the BusinessObjects\MySolutionDbContext.cs file as shown below.

    public class MySolutionDbContext : DbContext {
        public DbSet<Event> Events { get; set; }
        public DbSet<Resource> Resources { get; set; }
  • Rebuild the solution.
  • In the Solution Explorer, find the Module.cs (Module.vb) file within the MySolution.Module project. Double-click it to invoke the Module Designer.


  • In the Exported Types section, locate the Referenced Assemblies | DevExpress.Persistent.BaseImpl.EF.v20.2 | Event node. Select it and press the SPACEBAR, or right-click it and choose Use Type in Application in the invoked context menu. The node will be marked in bold. This means that the Event business class will be added to the Application Model, and this class will take part in the UI construction process. The use of extra modules is detailed in the Extra Modules section of this tutorial.


    If the Event class is not available in the Exported Types section, please ensure that your solution was rebuilt after registering this class in DbContext and restart the designer.

  • Run the WinForms or ASP.NET application and note that the Scheduler Event navigation item is created, as the Event class has the NavigationItemAttribute applied. Note that it may be necessary to add other classes from the Business Class Library to the navigation manually (see the Add an Item to the Navigation Control topic).



XAF has a special Scheduler module contains List Editor that uses the Scheduler Control (Win/Web) to display and manage Event business objects in XAF applications. Refer to the Add the Scheduler Module lesson to learn how to use it in your application.

You can see the code demonstrated in this lesson in the EF Demo (Code First) installed with XAF. By default, the EF Demo (Code First) application is installed in %PUBLIC%\Documents\DevExpress Demos 20.2\Components.NET Core Desktop Libraries\eXpressApp Framework\EFDemoCodeFirst.


Next Lesson: Set a Many-to-Many Relationship (EF 6)