Skip to main content
.NET 6.0+

XafApplication.CheckCompatibilityType Property

Specifies how the database and application compatibility is checked.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v23.2.dll

NuGet Package: DevExpress.ExpressApp

Declaration

[DefaultValue(CheckCompatibilityType.ModuleInfo)]
public CheckCompatibilityType CheckCompatibilityType { get; set; }

Property Value

Type Default Description
CheckCompatibilityType ModuleInfo

A CheckCompatibilityType enumeration value that specifies how database and application compatibility is checked.

Remarks

You can set CheckCompatibilityType to the following values.

Value

Description

DatabaseSchema

XAF performs the following checks:

  • The database exists.
  • All required tables exist.
  • All required columns exist (XPO only).

The XafApplication.DatabaseVersionMismatch event occurs if any of these checks fails. If the database does not exist, XAF creates the database and required tables. If the database exists, but it is empty, XAF creates the tables. If a column does not exist, XAF adds it to the table (only in applications that use XPO ORM).

In applications that use XPO ORM, XAF utilizes native XPO techniques to check the conditions. In applications that use Entity Framework Core ORM, XAF uses the EnsureCreated() method.

ModuleInfo

In this mode, XAF creates a ModuleInfo table in the database to check compatibility of an application and its database. This table stores information on the module versions used in the application. When XAF checks compatibility of the database and the application, the versions stored in the ModuleInfo table are compared with actual module versions. The XafApplication.DatabaseVersionMismatch event occurs in case of a mismatch.

If your application uses Entity Framework Core ORM, register the ModuleInfo type in DbContext.

Each module’s default version value is “1.0.*“ (specified by the AssemblyVersion attribute in the Properties\AssemblyInfo.cs file). The asterisk in the version number indicates that build and revision numbers are incremented automatically. XAF updates the version number with each new build. As a result, module versions may become unsynchronized if you build Windows Forms and ASP.NET Web Forms or ASP.NET Core Blazor applications separately (for example, when you create a ClickOnce installation or deploy to IIS).

This mode is more complicated compared to DatabaseSchema, but it helps you ensure both business logic compatibility and data model compatibility. To learn more about this mode, refer to the following topic: Update Application and Database Versions using the ModuleInfo Table.

You can change the CheckCompatibilityType property value in the Application Designer:

CheckCompatibilityType

XafApplication sets CheckCompatibilityType to its default value of ModuleInfo. However, an XafApplication descendant overrides the default value to DatabaseSchema in code generated by the Solution Wizard. This change preserves the behavior of applications created in earlier versions. The following example shows how this code may look:

// ...
public class MainDemoBlazorApplication : BlazorApplication {
    public MainDemoBlazorApplication() {
        // ...
        CheckCompatibilityType = DevExpress.ExpressApp.CheckCompatibilityType.DatabaseSchema;
        // ...
    }
}

Tip

Use the IObjectSpaceProvider.CheckCompatibilityType property to specify the mode individually for each Object Space Provider (in case you use multiple databases).

The following code snippets (auto-collected from DevExpress Examples) contain references to the CheckCompatibilityType property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also