How to: Add the Scheduler Module (.NET)
- 3 minutes to read
This article describes how to add the Scheduler module to .NET Windows Forms and ASP.NET Core Blazor applications.
The module implements a calendar component for scheduling appointments and events.
Step-by-Step Instructions
Add the DevExpress.ExpressApp.Scheduler NuGet package to the MySolution.Module project. See the following topic for more information on how to install DevExpress NuGet packages: Choose Between Offline and Online DevExpress NuGet Feeds.
In the Solution Explorer, go to the MySolution.Module project and open the Module.cs file. Add the Scheduler module to the RequiredModuleTypes collection. Then, add the
Event
andResource
classes to the AdditionalExportedTypes collection.In Entity Framework Core-based applications:
//... namespace MySolution.Module; //... public sealed class MySolutionModule : ModuleBase { public MySolutionModule() { //... RequiredModuleTypes.Add(typeof(DevExpress.ExpressApp.Scheduler.SchedulerModuleBase)); AdditionalExportedTypes.Add(typeof(DevExpress.Persistent.BaseImpl.EF.Event)); AdditionalExportedTypes.Add(typeof(DevExpress.Persistent.BaseImpl.EF.Resource)); } //... }
In XPO-based applications:
//... namespace MySolution.Module; //... public sealed class MySolutionModule : ModuleBase { public MySolutionModule() { //... RequiredModuleTypes.Add(typeof(DevExpress.ExpressApp.Scheduler.SchedulerModuleBase)); AdditionalExportedTypes.Add(typeof(DevExpress.Persistent.BaseImpl.Event)); AdditionalExportedTypes.Add(typeof(DevExpress.Persistent.BaseImpl.Resource)); } //... }
Optional. If you use Entity Framework Core, go to the MySolution.Module\BusinessObjects folder, open the MySolutionDbContext.cs file. Then, register the
Event
andResource
types in the application’sDbContext
://... namespace MyApplication.Module.BusinessObjects; //.. [TypesInfoInitializer(typeof(MySolutionContextInitializer))] public class MySolutionEFCoreDbContext : DbContext { public MySolutionEFCoreDbContext(DbContextOptions<MySolutionEFCoreDbContext> options) : base(options) { } public DbSet<Event> Events { get; set; } public DbSet<Resource> Resources { get; set; } //.. } // ...
Note
If you use Entity Framework Core, any changes to the application’s data model may cause database-related exceptions when you run the application. We recommend that you use migrations to update the database schema. For more information on how to create a migration and update the database, refer to the following topic: Implement a Data Model: Basics.
Add the following NuGet packages to platform-specific projects in your application:
- MySolution.Blazor.Server project: DevExpress.ExpressApp.Scheduler.Blazor
- MySolution.Win project: DevExpress.ExpressApp.Scheduler.Win
In ASP.NET Core Blazor application, navigate to the MySolution.Blazor.Server\Startup.cs file and call the AddScheduler(IModuleBuilder<IBlazorApplicationBuilder>, Action<SchedulerOptions>) method.
In Windows Forms application, navigate to the MySolution.Win\Startup.cs file and call the AddScheduler(IModuleBuilder<IWinApplicationBuilder>, Action<SchedulerOptions>) method.
public class Startup { // ... public void ConfigureServices(IServiceCollection services) { // ... services.AddXaf(Configuration, builder => { builder.UseApplication<MySolutionBlazorApplication>(); builder.Modules // ... .AddScheduler(); // ... }); // ... } }
Build the project and run the application. The Scheduler Event item appears in the navigation control.
- ASP.NET Core Blazor
- Windows Forms
Tip
XAF has a special Notifications module you can use to set notifications for events. For more information about this module, refer to the following topic: How to: Use Notifications with the Scheduler Event.