Skip to main content
.NET 6.0+

XafApplication.DatabaseVersionMismatch Event

Occurs when the application being run calls the database.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v23.2.dll

NuGet Package: DevExpress.ExpressApp

Declaration

public event EventHandler<DatabaseVersionMismatchEventArgs> DatabaseVersionMismatch

Event Data

The DatabaseVersionMismatch event's data class is DatabaseVersionMismatchEventArgs. The following properties provide information specific to this event:

Property Description
CompatibilityError Specifies the error that has occured while checking the database and application compatibility.
Handled Gets or sets a value that indicates whether the event handler has completely handled the event or whether the system should continue its own processing. Inherited from HandledEventArgs.
Updater Provides access to the Database Updater which is used to update the database version.

Remarks

Handle this event to compare the application version in the database and the actual application version, and update the database version if required. To do this, use the handler’s DatabaseVersionMismatchEventArgs.Updater parameter, which provides access to the DatabaseUpdater object. Set the handler’s Handled parameter to true, to prevent other database version updates.

Actually, you can find a handler of this event in the XXXApplication.cs (XXXApplication.vb) file of the Windows Forms or ASP.NET Web Forms application:

public partial class MySolutionWindowsFormsApplication : WinApplication {
   private static void MySolutionWindowsFormsApplication_DatabaseVersionMismatch(object sender, 
         DatabaseVersionMismatchEventArgs e) {
      if(System.Diagnostics.Debugger.IsAttached) {
         e.Updater.Update();
         e.Handled = true;
      }
   }
partial class MySolutionWindowsFormsApplication {
   //...
   private void InitializeComponent() {
      //...
      this.DatabaseVersionMismatch += MySolutionWindowsFormsApplication_DatabaseVersionMismatch;
      // ...
   }
   // ...
}

This handler updates the database when the application runs in the debugging mode. For details, refer to the Update Application and Database Versions using the ModuleInfo Table topic. If you need to perform custom code, rewrite this event handler.

After executing code in the DatabaseVersionMismatch event handler, the database and application are considered as compatible.

When you connect to the database via the Middle Tier Security server, the compatibility check is performed at the server side. You should unconditionally throw an exception when the DatabaseVersionMismatch event occurs at the client side (see Create and Update the Application’s Database).

If you handle the XafApplication.CustomCheckCompatibility event, you have to implement code that updates the database version, because the DatabaseVersionMismatch event will not be raised.

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

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