Ticket T879111
Visible to All Users

XPO - Database Schema Migrations

created 5 years ago (modified a year ago)

With v20.1, you can incrementally update your database schema once changes are made to an XPO data model. You can generate diffs (the SQL script) between the latest data model and the existing database schema in the ORM Data Model Designer or in code.

Supported Databases and Limitations

  • At present, the following data store providers support this feature: MSSqlConnectionProvider, MySqlConnectionProvider, OracleConnectionProvider, ODPConnectionProvider, ODPManagedConnectionProvider, PostgreSqlConnectionProvider.
  • The Database Schema Migration API (interfaces and method names) are subject to change.
  • The Data Model Designer does not allow you to specify custom schema migration options.
  • If you rename a class or property, the schema migration script will delete the corresponding table or column and create a new one.
  • The Data Model Designer cannot generate a database update script if the Data Model contains classes mapped to database views.
  • Custom (non-XPO) attributes are not supported by this feature.

How It Works

Right-click the design surface and select the Generate Migration Script menu item. The designer will add a new file with SQL commands and open it in Visual Studio.
Clipboard-File-1.png

If you create XPO classes manually, the following example demonstrates how to generate a schema migration script and update your database programmatically: XPO - How to use the Database Schema Migrations API.

Important Notes

Changes to the database schema can corrupt your data. Good practice is to create a full database backup before you update the database schema.

Show previous comments (5)
Dennis Garavsky (DevExpress) 4 years ago

    Hi, Sebastijan.

    This feature does not support Firebird. Frankly, we have not received much feedback for other database providers either.
    We will be happy to learn more about your schema migration scenarios and see how XPO can better meet your needs in the future.

    SB SB
    Sebastijan Baltic 4 years ago

      We are researching the options for multi-tenant Xaf (XPO) Blazor apps (yes, we know the limitations/recommendations of XAF from other tickets):

      REQUIREMENTS

      • Linux
      • Firebird DB

      #1 SOLUTION SCENARIO (same schema DB; please find attached file)
      Xaf Blazor Admin App (tenant list, other data)
      *responsible for migration automation per tenant (other (I think slower) option is calling Process.Start (program.cs with XafApplication IDBUpdater))
      Xax Blazor "Tenant" App

      • change (per tenant) connection string in runtime before login

      #2 IDEAL SCENARIO (per tenant XAF modules & schema)

      • but as I know this is problematic due to XAF architecture
      • I think this should be possible in the long term explicitly for Xaf Blazor, because of DI,
        XafApplication instance per user (browser tab)… so ideal scenario:
      1. change connection before login
      2. decide which modules to load, type system per application (non static)
      Andrey K (DevExpress Support) 4 years ago

        Hello,

        Thank you for sharing your scenario with us. We will contact you if we have any questions regarding it.

        Andrey

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.