🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
Bootcamp:Chapter 14
This page was created by Hans.karlsen on 2023-01-21. Last edited by Wikiadmin on 2026-07-29.

This chapter shows you how to run a local MDrivenServer, upload your model, move prototype data from XML persistence to the server database, and verify that model changes update the database schema. It is for Bootcamp learners who completed Training:Bootcamp:Chapter 13 and want to run their application against a relational database.

What you will do

MDrivenServer understands the model you upload and maintains a compatible database schema. In this chapter, you will:

  • Start two local server pairs for comparison.
  • Select an active MDrivenServer and upload the current model.
  • Inspect the uploaded model and data in the MDrivenServer web UI.
  • Export data from XML persistence and import it into MDrivenServer persistence.
  • Resolve a possible duplicate SysSingleton after migration.
  • Verify that adding, changing, and removing model elements changes the database schema.

A server pair consists of an MDrivenServer and a TurnkeyServer. Turnkey runs the web application; MDrivenServer hosts the uploaded model and its data.

Inspect the current XML prototype data

Before moving data to the server database, locate the XML file used by the local prototype.

  1. In MDriven Designer, press Play and start the Local Turnkey Prototyper. The web application starts.
  2. In the prototyper settings, find the file shown beside Use XML file for data. Locate that file on your computer.
  3. Open the XML file in Notepad or another text editor.
  4. Confirm that you recognize the objects you created earlier, such as Cars and Brands of Cars.

This file is the source data that you will export and import later in this chapter.

Install and start local server pairs

Use the Cloud-connection dialog to download and operate local server installations.

  1. Open the Cloud-connection dialog from the MDriven Designer toolbar.
  2. Download the latest version for Local servers.
  3. Add a server pair named Server1.
  4. Refresh the installation for Server1.
  5. Open the installation folder from its displayed file path and confirm that the installed files are present.
  6. Add a second server pair named Server2.
  7. Refresh the installation for Server2.
  8. Select Server1 and click Start Servers.
  9. Confirm that two command windows open: one for MDrivenServer and one for TurnkeyServer.
  10. Click Start Servers again to verify that the Server1 pair restarts.
  11. Start Server2 and confirm that two additional command windows open.

Choose and test the active MDrivenServer

The active MDrivenServer is the server that MDriven Designer uses when you upload the model and work with server persistence.

  1. Switch to the Active MDriven Server tab.
  2. Enter the Server1 MDrivenServer address: http://localhost:5000.
  3. Enter user name a and password 123456.
  4. Click Check Server status.
  5. Verify the initial status says Never started, No current version.
  6. Return to the Local Servers tab, select Server1, and click Use Above MDrivenServer.

Test that the selection follows the server you choose:

  1. Start or select the Server2 pair.
  2. Make Server2 active and check its server status.
  3. Close the two Server2 command windows. These use ports 5002 and 5003.
  4. Click Check Server status again.
  5. Verify that the check times out because the selected server address is no longer running.
  6. Return to Local Servers, select Server1, and click Use Above MDrivenServer.
  7. Confirm that the green indicator shows http://localhost:5000.

Upload the model and inspect the server

Upload the current model to create its initial server-side representation and database schema.

  1. In the Cloud-connection dialog, click Upload model.
  2. Click Check Server Status. If the response is incomplete, wait briefly and click it again.
  3. Verify that the status reports that the database was created.
  4. Click Update ServerSide jobs. No jobs are expected at this point because this Bootcamp has not yet defined server-side jobs.
  5. Open http://localhost:5000 in a browser.
  6. Sign in with user name a and password 123456.
  7. Open Running, then choose Model. Confirm that the uploaded model is shown.
  8. Open Running, then select Data in A0.
  9. Select the Car class and click Search. At this stage, verify that no Car data is present in the server database.

The credentials in this exercise are used for a localhost server. Do not treat them as credentials for a server that users can access over a network.

Migrate XML data to MDrivenServer persistence

Export the objects in your XML prototype, then import them into the database managed by MDrivenServer.

Export the XML prototype data

  1. Return to MDriven Designer and press Play.
  2. In the System Prototyper, select XML persistence and click Start system.
  3. Click Migrate.
  4. In the Migrate window, click the green button.
  5. Save the exported data as migrateToDB.xml.
  6. Close the Migrate dialog.

Import the data into MDrivenServer

  1. Switch the System Prototyper to MDrivenServer persistence.
  2. Click Start system.
  3. Click Migrate.
  4. Click the pink button, select migrateToDB.xml, and click Open.
  5. Review the reported number of objects created and relations set.
  6. Click the yellow button to save the imported data.
  7. Return to the MDrivenServer web UI at http://localhost:5000.
  8. Open Running, then Data in A0. Select Car and click Search.
  9. Verify that Cars are now present.
  10. Double-click a Car in the result list and verify that an AutoForm displays its data.
  11. For the BrandOfCar single link, click Open. Verify that the Brand AutoForm shows the related data, including the brand image.

Run Turnkey against MDrivenServer

Switch the local Turnkey prototype from XML persistence to the selected MDrivenServer.

  1. In MDriven Designer, select the LocalTurnkeyPrototyper tab and click Play.
  2. In the System Prototyper, change Data from Use XML file for data to Use MDriven Server.
  3. Click Restart to apply the setting to the Turnkey Prototyper.
  4. Test the spawned web application.

Fix a duplicate SysSingleton error

After migration, the web application can display this error:

The Singleton class SysSingleton has multiple instances

A singleton is a class intended to have one object. In this model, SysSingleton uses the OCL operation oclSingleton; if no instance exists, that operation can recreate one when it is first requested. The migration may have imported one SysSingleton while another instance already existed.

If you see the error, delete one instance. If you do not see the error, you can inspect the data but do not delete an instance unnecessarily.

  1. In MDriven Designer, open Play and choose MDrivenServer persistence.
  2. Click Start system, then open the debugger.
  3. In the class picker, select SysSingleton.
  4. Click Select 50, then click Execute (F5). Confirm whether two objects are listed.
  5. Click Seeker, then Search.
  6. Select one SysSingleton object and click Delete Selected. Leave one instance, or leave none if you intend oclSingleton to recreate it.
  7. Return to the main debugger form and click Save.
  8. Refresh the failed web page with F5 and verify that the application works.

Verify database schema updates from model changes

When MDrivenServer persistence is active, changing the model requires a corresponding database schema change. Uploading the model lets MDrivenServer apply that change.

  1. Add a new class named Class1 to the model.
  2. Open the Cloud-connection dialog and click Upload Model.
  3. Click Check Server Status. If there is no new feedback, wait one second and check again.
  4. Verify that the status reports a new table for objects of Class1.
  5. Add several attributes to Class1, upload the model, and verify that the status reports schema changes for the new attributes.
  6. Delete some of those attributes, upload again, and verify that the status reports removed columns.
  7. Add an association between Class1 and BrandOfCar.
  8. Upload the model and verify that the status reports added columns for the foreign key. At the database level, this foreign key stores the primary key of the associated object.
  9. Delete the experimental Class1 class.
  10. Upload the model and verify that the status reports that the Class1 table and the association foreign-key column were dropped.

Next steps

For deployment beyond your development machine, run MDrivenServer and MDrivenTurnkey on a server that your intended users can reach, such as an internal company network or an internet-accessible server. Continue with Training:Bootcamp:Chapter 15.

See also