Log in

The 1000 steps program to MDriven Chapter 14

From MDrivenWiki

This is Chapter 14. If you want to go back to the beginning, you can find it here: Chapter 1. Or go back to Chapter 13.

Video 14_MDrivenEducationVideo:

Chapter 14

In this chapter, we'll go over the installation and initial use of the MDrivenServer for development. The MDrivenServer makes your application enterprise-grade and allows you to connect to your own database with a connection string. The MDrivenServer understands your model and offloads you of all the hassle of keeping your DB-schema compatible with your system needs.

407. Press the play button and start the Turnkey prototyper.

408. Find the XML file that stores the data.

409. Open the XML file with Notepad and take a look to see that you recognize it.

410. Open the Cloud-connection dialog from the toolbar.

411. Download the latest for Local servers.

412. Add a server-pair - Server1

413. Refresh the install to Server1

414. Open the install folder and make sure you see the files.

415. Add another server-pair: Server2

416. Refresh the install for Server2

417. Start Server1

418. Ensure you see 2 command windows, one for the MDrivenServer and one for the TurnkeyServer.

419. Try to press Start Servers again to verify that the server pair re-starts.

420. Start Server2. Ensure you see 2 new cmd windows.

421. Pick Server1's MDrivenServer as the active MDrivenServer by first switching the tab to "Active MDriven Server".

422. Type in the address of the MDrivenServer http://localhost:5000 - also, type user a and password 123456

423. Press Check Server status. Verify that it says "Never started, No current version".

424. Head back to the "Local Servers" tab and use the "Use above MDrivenServer" button to choose Active MDriven Server.

425. Try to start the Server2 pair. Choose it as Active and check its Server status.

426. Stop the cmd-windows for the Server2 pair (Ports 5002 and 5003). Now click on "Check server status" again.

427. Verify you get the expected timeout due to the server address being closed.

428. Switch back to the "Local servers" tab, pick Server1 and click Use Above MDrivenServer.

429. Verify that the green indicator shows http://localhost:5000

430. Press "Upload model" button. This will upload your current model to the active MDrivenServer.

431. Press "Check Server Status" button. If you do it too quickly after the upload, you will not get a full result. If you do so, click again.

432. Verify the returned result states that the database was created for us.

433. Also, press "Update serverside jobs" for good measure. Since we have not covered or defined server-side jobs yet, the result will be nothing.

434. Go to the MDrivenServer Web-UI by entering http://localhost:5000 in a browser.

435. Login with a and 12345 (the weak password is okay since this server is on localhost and can only be reached by users allowed on your machine).

436. Go to Running, choose Model.

437. Go to Running in Data in A0, choose Car, Search - verify that there is no data.

438. Migrate data into the DB. Start by pressing play.

439. Start the system with XML persistence.

440. Press Migrate, then the Green button inside the Migrate window. Save the data to migrateToDB.xml

441. Close Migrate dialog, switch to MDrivenServer persistence, and start the system. Press the Migrate button again.

442. Now click on the pink button, choose the migrateToDB.xml file, then select the yellow button to save the data.

443. Head back to the MDrivenServer web UI, Running/Data in A0/Car search - verify that you now have the data.

444. Double-click one of the Cars in the search result. Verify that you get an AutoForm displaying the data.

445. Click the "Open" behind BrandOfCar single-link and verify that you get the Brand-AutoForm, showing the data including the image of the brand.

446. Click on the "Play" button, in the LocalTurnkeyPrototyper tab, switch the "Data" from "Use XML" to "Use MDriven Server".

447. Press restart to apply the changed settings to the Turnkey-prototyper.

448. In the spawned web page, we may now see an error: "Singleton class SysSingleton has multiple instances".

449. If you see this error, use the following steps to fix it. If you do not have the error, follow the steps but avoid any data.

450. The error is an effect of the migration migrated in one instance of SysSingleton, and the system already had instances of SysSingleton - totalling to 2. The Singleton-concept does, however, force us to have only 1 object. In order to fix it, we must reach in and delete one of the instances of the SysSingleton, leaving only 1, or 0, because if 0, the oclSingleton operator will recreate it for us when we first ask for it.

451. To remove the extra SysSingleton: go to "Play"/MDrivenServer persistence/ start the system - click the debugger. Find the SysSingleton in the classes picker, click "Seeker", search and see the 2 objects. Select one of them, click "delete selected", and head back to the main debugger form. Click save.

452. Now go back to the failed web page and press F5. Verify that the app now works as before.

453. We are now running against a relational database controlled by the MDrivenServer. This means that we must change the schema (definition of DB tables and DB columns) in the database whenever we change things in our model.

  • Start by adding a new class Class1, and head over to the cloud-connection dialog.
  • Click "Upload Model".

454. Click "Check Server status". If you get no new feedback, wait 1 second, then press again.

455. Verify that the feedback from the server states that a table for storing objects of Class1 has been added to the database for us.

456. Add a few attributes to Class1, then upload the model again, and verify that the MDrivenServer status says the database schema was changed to accommodate the new attributes.

457. Delete some of the attributes and upload the model again. Verify that MDrivenServerStatus indicates that the MDrivenServer has removed columns from the table.

458. Add an association between Class1 and BrandOfCar, for example. Upload the model and verify that MDrivenServerStatus indicates that the MDrivenServer has added columns to store the foreign key - which will hold the primary key of an object-  that constitutes the association on the database level.

459. Now delete this experimental Class1, upload the model, and verify that MDrivenServerStatus indicates that the MDrivenServer has dropped the table for Class1 and also drops the column for the foreign key in BrandOfCar.

460. To learn more about the MDriven Server, look up MDriven Server on

461. When you are ready to deploy your application to a wider audience, you will want to run the MDrivenServer and MDrivenTurnkey on a server to which your users have access. This may be a company's internal network or on the internet.

  • You can always refer to to find out how to install the software on either a Microsoft Internet Server or on an Azure web application or run the core servers from Linux-based servers.

Next Chapter: