expressappframework-devexpress-dot-expressapp-dot-xafapplication-92ec4f7e.md
Specifies the database update mode.
Namespace : DevExpress.ExpressApp
Assembly : DevExpress.ExpressApp.v25.2.dll
NuGet Package : DevExpress.ExpressApp
[Browsable(false)]
[DefaultValue(DatabaseUpdateMode.UpdateOldDatabase)]
public DatabaseUpdateMode DatabaseUpdateMode { get; set; }
<Browsable(False)>
<DefaultValue(DatabaseUpdateMode.UpdateOldDatabase)>
Public Property DatabaseUpdateMode As DatabaseUpdateMode
| Type | Default | Description |
|---|---|---|
| DatabaseUpdateMode | UpdateOldDatabase |
Update mode.
|
Available values:
| Name | Description |
|---|---|
| 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.
|
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.
protected override void OnSetupStarted() {
base.OnSetupStarted();
if(System.Diagnostics.Debugger.IsAttached && CheckCompatibilityType == CheckCompatibilityType.DatabaseSchema) {
DatabaseUpdateMode = DatabaseUpdateMode.UpdateDatabaseAlways;
}
// ...
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.
builder.AddBuildStep(application => {
if (application.CheckCompatibilityType == CheckCompatibilityType.DatabaseSchema) {
application.DatabaseUpdateMode = DatabaseUpdateMode.UpdateDatabaseAlways;
// ...
protected override void OnSetupStarted() {
base.OnSetupStarted();
DatabaseUpdateMode = DatabaseUpdateMode.Never;
}
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.
if(System.Diagnostics.Debugger.IsAttached && application.CheckCompatibilityType == CheckCompatibilityType.DatabaseSchema) {
application.DatabaseUpdateMode = DatabaseUpdateMode.UpdateDatabaseAlways;
}
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
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
if(System.Diagnostics.Debugger.IsAttached && application.CheckCompatibilityType == CheckCompatibilityType.DatabaseSchema) {
application.DatabaseUpdateMode = DatabaseUpdateMode.UpdateDatabaseAlways;
}
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
If System.Diagnostics.Debugger.IsAttached AndAlso winApplication.CheckCompatibilityType = CheckCompatibilityType.DatabaseSchema Then
winApplication.DatabaseUpdateMode = DatabaseUpdateMode.UpdateDatabaseAlways
End If
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))
If System.Diagnostics.Debugger.IsAttached AndAlso WebApplication.Instance.CheckCompatibilityType = CheckCompatibilityType.DatabaseSchema Then
WebApplication.Instance.DatabaseUpdateMode = DatabaseUpdateMode.UpdateDatabaseAlways
End If
See Also