Schemas - HomeroThompson/firehawk GitHub Wiki

Schemas

Schemas allow to logically group database objects like tables, views, stored procedures, etc. Firehawk lets you map database Tables into Schemas based on conventions.

Before seeing the details of the schema conventions is worth to mention that:

  • Although NHibernate allows to set the schema name when mapping an entity to a table not all the databases support schemas.
  • NHibernate SchemaExport tool does not create sql server schemas, so the schema objects must exist on the target database before exporting the model. Said that, next is the list of available conventions when mapping database tables to schemas:
Default

Tables are not mapped to a schema, so the database assigns the default schema to each one. (Commonly named dbo). This is the default behavior so there is no need to set this value explicitly.

.ConfigureNamingConventions()
  .UseConventionForSchemaNames(SchemasNamingConvention.Default)
.EndConfig()
Assembly Name

Each table is mapped to a schema whose name is equal to the name of the assembly that contains the corresponding entity.

.ConfigureNamingConventions()
  .UseConventionForSchemaNames(SchemasNamingConvention.AssemblyName)
.EndConfig()
Namespace Name

Each table is mapped to a schema whose name is equal to the suffix of the namespace that contains the corresponding entity.

.ConfigureNamingConventions()
  .UseConventionForSchemaNames(SchemasNamingConvention.NamespaceName)
.EndConfig()
Custom Name

Each table is mapped to a schema whose name is generated by an user-defined function. This function takes as input parameter the type of the corresponding entity.

.ConfigureNamingConventions()
  .UseCustomConventionForSchemaNames(t => "myschema")
.EndConfig()