The requested page is not available for the requested platform. You are viewing the content for Default platform.

XafApplication.DatabaseVersionMismatch Event

Occurs when the application being run calls the database.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v19.1.dll

Declaration

public event EventHandler<DatabaseVersionMismatchEventArgs> DatabaseVersionMismatch
Public Event DatabaseVersionMismatch As EventHandler(Of DatabaseVersionMismatchEventArgs)

Event Data

The DatabaseVersionMismatch event handler receives an argument of the DatabaseVersionMismatchEventArgs type. 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 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 += new EventHandler<DatabaseVersionMismatchEventArgs>(
         this.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 Application 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.

See Also