SQL Server Compact (DatabaseCompact) is the legacy embedded administration database for MDrivenServer, intended for Windows installations and for administrators who need to inspect, recover, or switch the server's startup database.
What DatabaseCompact is
DatabaseCompact.sdf is a SQL Server Compact database stored in the MDrivenServer App_Data folder. MDrivenServer uses it as its administration database: it contains server settings and the server's own administration data.
For example, a Windows MDrivenServer installation can start with App_Data/DatabaseCompact.sdf as its administration database. The modeled application tables in this database have the A0_ prefix, while MDrivenServer administration tables have the Admin_ prefix.
SQL Server Compact does not work on Linux or macOS. VistaDB replaces DatabaseCompact as the embedded administration database for installations that must run outside Windows.
Startup database selection
When a new MDrivenServer has no valid administration database, it selects its startup database from files in MDrivenServer/App_Data.
| Condition at startup | File copied | Database used after startup |
|---|---|---|
UseVistaDBIfThisFileExists.xml is present
|
DatabaseVistaDB_TkStartDb.vdb6 is copied to DatabaseVistaDB.vdb6
|
VistaDB |
| The VistaDB selection file is absent | DatabaseCompact_TkStartDb.sdf is copied to DatabaseCompact.sdf
|
SQL Server Compact |
Once MDrivenServer has created and selected an administration database, it continues to use that database. Do not select DatabaseCompact for a Linux or macOS server.
Switch back to DatabaseCompact
Use this procedure when your MDrivenServer runs on Windows and you need it to create and use the SQL Server Compact administration database again.
- Stop MDrivenServer.
- Open the
MDrivenServer/App_Datafolder. - Rename or remove
DatabaseVistaDB.vdb6so MDrivenServer cannot find it. - Rename
UseVistaDBIfThisFileExists.xmlso it is hidden from MDrivenServer startup. - Start MDrivenServer.
- Confirm that MDrivenServer has created
DatabaseCompact.sdffromDatabaseCompact_TkStartDb.sdf.
Keep a backup before renaming or deleting an administration database. The administration database contains server configuration and administration data.
Open a DatabaseCompact file
You can inspect a downloaded DatabaseCompact.sdf file with LinqPad.
- Open the
.sdffile in LinqPad. - Select the SQL CE 4.0 driver.
- If LinqPad cannot find that driver, install the Microsoft SQL Server Compact 4.0 database driver and restart LinqPad.
For example, open Admin_GlobalSettings to inspect server-wide settings, or inspect tables beginning with A0_ to view modeled application data.
Password recovery
If you have access to the server files, reset the password without editing the database directly.
- In
MDrivenServer/App_Data, createPwdReset.txt. - Put only the required new password in the file.
- Save and close the file.
- Restart MDrivenServer.
At startup, MDrivenServer applies the password to user a, unlocks that user if needed, and deletes PwdReset.txt after reading it.
If you are locked out and must edit the database, see opening the built-in database for the relevant administration tables and lockout behavior.
Corrupt administration database
A DatabaseCompact.sdf file can be corrupted between deployments and then fail to evolve correctly. If this occurs, use the recovery approach in Corrupt MDriven Server. The recovery tool reads ECO_ORMAPPING from a matching, working compact database and writes it to the corrupt database.
Use a database from the same MDrivenServer version when possible. Back up the corrupt database before applying the mapping.
Use in sample applications
Some MDriven Turnkey samples are distributed with DatabaseCompact files. For example, InstantPoll provides DatabaseCompact ForInstantPoll.zip, and ProjectPlanner provides ProjectPlanner DatabaseCompact.zip.
