Fork me on GitHub

Configuring the Database Schema Edit on GitHub


By default, Marten will put all database schema objects into the main public schema. If you want to override this behavior, use the StoreOptions.DocumentSchemaName property when configuring your IDocumentStore:


StoreOptions(_ =>
{
    _.Storage.MappingFor(typeof(User)).DatabaseSchemaName = "other";
    _.Storage.MappingFor(typeof(Issue)).DatabaseSchemaName = "overriden";
    _.Storage.MappingFor(typeof(Company));
    _.Storage.MappingFor(typeof(IntDoc));

    // this will tell marten to use the default 'public' schema name.
    _.DatabaseSchemaName = Marten.StoreOptions.DefaultDatabaseSchemaName;
});

As you can see, you can also choose to configure the schema storage for each document type individually.