Is there a way to tell NHibernate to use square brackets for all table and column names (like [MyColumn]
) when generating the SQL schema export for MS SQL Serve
You need to use (or write) the correct dialect for your database
Use backticks in your mapping files around the column names. NH should replace these with the correct character for your db dialect (in your case square brackets).
i.e. use:
<class name="SomeClass" table="`SomeTable`">
NB - It won't work with an apostrophe. The backtick is located top left on most keyboards.
Easier approach:
SchemaMetadataUpdater.QuoteTableAndColumns(config)
(Before building SessionFactory)
That will quote all the reserved names automatically.