🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
MultiTenantPrefix
This page was created by Hans.karlsen on 2022-02-19. Last edited by Wikiadmin on 2026-07-29.

You can use MultiTenantPrefix on an SQL SqlDatabaseConfig to keep the tables for separate MDriven models isolated within one database instance.

What MultiTenantPrefix does

MultiTenantPrefix is a property of SqlDatabaseConfig. When you set it, MDriven adds the specified text at the start of every table name it creates.

The prefix also limits schema management operations:

  • Create creates tables using the configured prefix.
  • Evolve considers tables with the configured prefix.
  • Tables with no prefix, or with a different prefix, are ignored by Create and Evolve.

This lets you store multiple MDriven-created database schemas in the same database instance without having one model's Create or Evolve operation act on another model's tables.

Example

Assume that two MDriven models use the same database instance:

Model configuration Example created table Tables handled by Create and Evolve
MultiTenantPrefix = "Sales_" Sales_Customer Tables beginning with Sales_
MultiTenantPrefix = "Support_" Support_Case Tables beginning with Support_
No prefix configured Customer Unprefixed tables

With the Sales_ configuration, MDriven creates and evolves tables such as Sales_Customer. It ignores Support_Case and an unprefixed table such as Customer.

Configure a prefix

  1. Locate the SqlDatabaseConfig used by the application or model.
  2. Set its MultiTenantPrefix property to the prefix that identifies this model's tables.
  3. Use the same prefix whenever that model runs Create or Evolve against this database.
  4. Configure every other model sharing the database with its own distinct prefix.

Choose the prefix before creating the schema. Changing the configured prefix changes which tables Create and Evolve recognize. A model configured with a new prefix will ignore the tables created under its previous prefix.

MDrivenServer BuiltInDB

In MDrivenServer, the server's own model uses the Admin_ prefix. If you choose BuiltInDB for an uploaded model, that uploaded model uses the A0_ prefix.

For example, a table belonging to the MDrivenServer model is prefixed with Admin_, while a table belonging to the uploaded BuiltInDB model is prefixed with A0_. The prefixes keep the two sets of tables separate in the same database instance.

Scope and related persistence settings

MultiTenantPrefix concerns SQL table naming and the tables considered by Create and Evolve. It does not define application authorization or user access; see Documentation:Access control system in MDriven for access-control guidance.

For broader SQL persistence configuration and mapping behavior, see Documentation:Working with Code and Persistence Mapping. If you need to change how classes map to tables or columns, see Documentation:Custom OR Mapping.

See also