Fluent NHibernate
Mapping Patterns Schemas

This is part of the Mapping Patterns collection.

Sometimes you may need to map a table that is in a different schema than the rest of your tables, to do this you need to use the SchemaIs method on the ClassMap of your entity.

public class PersonMap : ClassMap<Person>
{
  public PersonMap()
  {
    SchemaIs("alternativeSchema");
  }
}

If you want to explicitly specify the schema for all the entities in your application, then you can use the Database Configuration to set that. There's also evidence that explicitly setting the schema can yield performance increases for querying.

To set the schema for your entire application, use the DefaultSchema method on your favorite Database Configuration.

MsSqlServerConfiguration.MsSql2005
  .DefaultSchema("dbo");