Back to Devexpress

XafApplication.DatabaseUpdateMode Property

expressappframework-devexpress-dot-expressapp-dot-xafapplication-92ec4f7e.md

latest9.2 KB
Original Source

XafApplication.DatabaseUpdateMode Property

Specifies the database update mode.

Namespace : DevExpress.ExpressApp

Assembly : DevExpress.ExpressApp.v25.2.dll

NuGet Package : DevExpress.ExpressApp

Declaration

csharp
[Browsable(false)]
[DefaultValue(DatabaseUpdateMode.UpdateOldDatabase)]
public DatabaseUpdateMode DatabaseUpdateMode { get; set; }
vb
<Browsable(False)>
<DefaultValue(DatabaseUpdateMode.UpdateOldDatabase)>
Public Property DatabaseUpdateMode As DatabaseUpdateMode

Property Value

TypeDefaultDescription
DatabaseUpdateModeUpdateOldDatabase

Update mode.

|

Available values:

NameDescription
Never

The database is never updated automatically. You should update the database manually on the database server.

| | UpdateDatabaseAlways |

The database is updated at every application run. Do not choose this mode when the Middle Tier Application Server is in use.

| | UpdateOldDatabase |

The database is updated when its version is older than the application version.

|

Remarks

Use this property to specify when the application database should be updated: at every application run, when its version is older than the application version, or never (manually).

The DevExpress Template Kit sets the DatabaseUpdateMode property for new applications to the UpdateDatabaseAlways value in Debug mode.

csharp
protected override void OnSetupStarted() {
    base.OnSetupStarted();
    if(System.Diagnostics.Debugger.IsAttached && CheckCompatibilityType == CheckCompatibilityType.DatabaseSchema) {
        DatabaseUpdateMode = DatabaseUpdateMode.UpdateDatabaseAlways;
    }
    // ...
csharp
builder.AddBuildStep(application => {
    application.ConnectionString = connectionString;
    if(System.Diagnostics.Debugger.IsAttached && application.CheckCompatibilityType == CheckCompatibilityType.DatabaseSchema) {
        application.DatabaseUpdateMode = DatabaseUpdateMode.UpdateDatabaseAlways;
    }
    // ...

If your application includes Middle Tier Application Server, the server application must update the database. Updating from client applications must be disabled.

For new applications with a Middle Tier Server, the Template Kit disables the autoupdate in client applications and enables it in the Middle Tier server application.

csharp
builder.AddBuildStep(application => {
    if (application.CheckCompatibilityType == CheckCompatibilityType.DatabaseSchema) {
        application.DatabaseUpdateMode = DatabaseUpdateMode.UpdateDatabaseAlways;
        // ...
csharp
protected override void OnSetupStarted() {
    base.OnSetupStarted();
    DatabaseUpdateMode = DatabaseUpdateMode.Never;
}
csharp
builder.AddBuildStep(application => {
    application.DatabaseUpdateMode = DatabaseUpdateMode.Never;
});

The following code snippets (auto-collected from DevExpress Examples) contain references to the DatabaseUpdateMode 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.

xaf-how-to-show-a-custom-form-as-the-winforms-dashboard-designer/CS/XPO/DashBoardCustomForm/DashBoardCustomForm.Win/Startup.cs#L40

csharp
if(System.Diagnostics.Debugger.IsAttached && application.CheckCompatibilityType == CheckCompatibilityType.DatabaseSchema) {
    application.DatabaseUpdateMode = DatabaseUpdateMode.UpdateDatabaseAlways;
}

xaf-how-to-access-the-master-detailview-information-from-a-nested-listview-controller/CS/XPO/GetMasterFrame/GetMasterFrame.Win/Startup.cs#L30

csharp
if(System.Diagnostics.Debugger.IsAttached && application.CheckCompatibilityType == CheckCompatibilityType.DatabaseSchema) {
    application.DatabaseUpdateMode = DatabaseUpdateMode.UpdateDatabaseAlways;
}

xaf-how-to-extend-the-application-model/CS/XPO/ExtendModel/ExtendModel.Win/Startup.cs#L30

csharp
if(System.Diagnostics.Debugger.IsAttached && application.CheckCompatibilityType == CheckCompatibilityType.DatabaseSchema) {
    application.DatabaseUpdateMode = DatabaseUpdateMode.UpdateDatabaseAlways;
}

xaf-save-and-share-custom-view-settings/CS/XPO/ViewSettings/ViewSettings.Win/Startup.cs#L44

csharp
if(System.Diagnostics.Debugger.IsAttached && application.CheckCompatibilityType == CheckCompatibilityType.DatabaseSchema) {
    application.DatabaseUpdateMode = DatabaseUpdateMode.UpdateDatabaseAlways;
}

XAF-CRUD-for-Non-Persistent-Objects-Stored-Remotely/CS/NonPersistentObjectsDemo.Web/Global.asax.cs#L46

csharp
if(System.Diagnostics.Debugger.IsAttached && WebApplication.Instance.CheckCompatibilityType == CheckCompatibilityType.DatabaseSchema) {
    WebApplication.Instance.DatabaseUpdateMode = DatabaseUpdateMode.UpdateDatabaseAlways;
}

XAF-CRUD-for-Non-Persistent-Objects-Stored-Remotely/VB/NonPersistentObjectsDemo.Win/Program.vb#L47

vb
If System.Diagnostics.Debugger.IsAttached AndAlso winApplication.CheckCompatibilityType = CheckCompatibilityType.DatabaseSchema Then
    winApplication.DatabaseUpdateMode = DatabaseUpdateMode.UpdateDatabaseAlways
End If

XAF-implement-custom-permission-role-and-user-objects/VB/SecuredExportExample.Win.MiddleTierSecurityClient/Program.vb#L43

vb
winApplication.ConnectionString = "net.tcp://127.0.0.1:1451/DataServer"
winApplication.DatabaseUpdateMode = DatabaseUpdateMode.Never
Dim wcfSecuredClient As New WcfSecuredClient(WcfDataServerHelper.CreateNetTcpBinding(), New EndpointAddress(winApplication.ConnectionString))

XAF_how-to-store-file-attachments-in-the-file-system-instead-of-the-database/VB/E965.Web/Global.asax.vb#L46

vb
If System.Diagnostics.Debugger.IsAttached AndAlso WebApplication.Instance.CheckCompatibilityType = CheckCompatibilityType.DatabaseSchema Then
    WebApplication.Instance.DatabaseUpdateMode = DatabaseUpdateMode.UpdateDatabaseAlways
End If

See Also

Production Database and Application Updates

XafApplication Class

XafApplication Members

DevExpress.ExpressApp Namespace