How Documents are Stored

TODO -- feel like this is covered in the /document part and was copied there, so delete this page.

Marten will create a new database table and upsert function for each document type. By default, the table name is mt_doc_[alias] and the function is mt_upsert_[alias], where "alias" is the document type name in all lower case letters, or "parent type name + inner type name" for nested types.

In the not unlikely case that you need to disambiguate table storage for two or more documents with the same type name, you can override the type alias either programmatically with MartenRegistry:

var store = DocumentStore.For(_ =>
{
    _.Connection(ConnectionSource.ConnectionString);

    _.Schema.For<User>().DocumentAlias("folks");
});

snippet source | anchor

or by decorating the actual document class with an attribute:

[DocumentAlias("johndeere")]
public class Tractor
{
    public string id;
}

snippet source | anchor