NHibernate: forcing square brackets in schema export?

前端 未结 3 839
[愿得一人]
[愿得一人] 2021-01-18 03:40

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

相关标签:
3条回答
  • 2021-01-18 04:20

    You need to use (or write) the correct dialect for your database

    0 讨论(0)
  • 2021-01-18 04:21

    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.

    0 讨论(0)
  • 2021-01-18 04:31

    Easier approach:

    SchemaMetadataUpdater.QuoteTableAndColumns(config)
    

    (Before building SessionFactory)

    That will quote all the reserved names automatically.

    0 讨论(0)
提交回复
热议问题